Comments (7)
@ve3 We can catch to exception about server connection failure.
I think that isConnect
was not needed.
When you used code like next, you would catch to exception to server connection failure.
<?php
use ElephantIO\Client,
ElephantIO\Engine\SocketIO\Version1X,
ElephantIO\Exception\ServerConnectionFailureException;
require __DIR__ . '/../../../../vendor/autoload.php';
$client = new Client(new Version1X('http://localhost:1337'));
try
{
$client->initialize();
$client->emit('broadcast', ['foo' => 'bar']);
$client->close();
}
catch (ServerConnectionFailureException $e)
{
echo 'Server Connection Failure!!';
}
from elephant.io.
@kbu1564 No, I cannot use try catch.
I was tried this before but the Elephant.IO throw the error before it pass to catch the error. That's why i need isConnected()
method.
from elephant.io.
@ve3 I think that you were not used to namespace of ElephantIO\Exception\ServerConnectionFailureException.
If you were not used about namespace, you can modify like next. :)
<?php
use ElephantIO\Exception\ServerConnectionFailureException;
$client = new \ElephantIO\Client(new \ElephantIO\Engine\SocketIO\Version1X('http://localhost:1337'));
try
{
$client->initialize();
$client->emit('broadcast', ['foo' => 'bar']);
$client->close();
}
catch (ServerConnectionFailureException $e)
{
echo 'Server Connection Failure!!';
}
from elephant.io.
I was tried that exactly you said and i was tried more than twice but It did not work.
"An error occurred while trying to establish a connection to the server"
This error was throw before it can catch
Please try it yourself first.
from elephant.io.
Quote:
ElephantIO\Exception\ServerConnectionFailureException [ Error ]:
An error occurred while trying to establish a connection to the server
((file location:)) wisembly/elephant.io/src/Engine/SocketIO/Version1X.php @ line 144
144 throw new ServerConnectionFailureException;
You cannot prevent thrown error (http://stackoverflow.com/questions/8835004/php-throw-exception-is-caught-but-the-error-message-still-appear).
I just want to use socket.io as optional, that's why when it is not connected I want it just pass without throwing the error.
And that's why i needs isConnected
. There is no other way to do this except making something to check the connection.
from elephant.io.
As @kbu1564 said, this exception occurs only on the handshake... which is catchable. When using write
, a check is made to check if the connection is made, and does nothing it the connection is not active. The try catch should do the trick (we're using it just fine here at Wisembly, with the dialog being optionnal)
I don't really see the point for a isConnected
method...
from elephant.io.
Ok, I found the point of this problem now, thank you all.
@Taluu @kbu1564
from elephant.io.
Related Issues (20)
- SSL routines:SSL_write:protocol is shutdown HOT 7
- In Version1X.php line 194: Notice: Undefined index: upgrades HOT 8
- Set headers over SSL HOT 2
- readBytes while when fread return empty string
- Read and emit message from php HOT 1
- Path in socket connection HOT 1
- Get Session for distribute login user data?
- Slowness issue HOT 1
- oncesk/elephant.io for php7 HOT 1
- socket.io 3 HOT 9
- connect to socket io of ws://
- connection event not being called HOT 2
- An error occurred while trying to establish a connection to the server HOT 4
- Is Elephant.io can be used to connect through websocket?
- elephant.io is 100% down hard. HOT 1
- Fatao Error: ServerConnectionFailureException HOT 2
- did someone tried to use it with socket.io version 4x ? HOT 1
- suddenly can't establish connection with server HOT 4
- Using Version2X but getting a Version1X error ? HOT 4
- UnexpectedValueException "The server returned an unexpected value. Expected "HTTP/1.1 101", had "HTTP/1.1 400"" #217 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elephant.io.