elephant.io
elephant.io copied to clipboard
Connection Error
When I try to node server, I get the error below:
Fatal error: Uncaught ElephantIO\Exception\ServerConnectionFailureException: An error occurred while trying to establish a connection to the server in /var/www/html/shared/socket-io/vendor/wisembly/elephant.io/src/Engine/SocketIO/Version1X.php:187 Stack trace: #0 /var/www/html/shared/socket-io/vendor/wisembly/elephant.io/src/Engine/SocketIO/Version1X.php(48): ElephantIO\Engine\SocketIO\Version1X->handshake() #1 /var/www/html/shared/socket-io/vendor/wisembly/elephant.io/src/Client.php(60): ElephantIO\Engine\SocketIO\Version1X->connect() #2 /var/www/html/shared/classes/socket.class.php(24): ElephantIO\Client->initialize() #3 /var/www/html/dashboard/news.php(83): Socket->__construct() #4 {main} thrown in /var/www/html/shared/socket-io/vendor/wisembly/elephant.io/src/Engine/SocketIO/Version1X.php on line 187
It is strange that when I use Version 2X still I get the same error. Actually it connects the server but throw the error and stop working.
Please catch the exception and dump the content of getErrorMessage().
getErrorMessage() function returns NULL. When I dump the content of '$e(error)', I get the line below:
object(ElephantIO\Exception\ServerConnectionFailureException)#39 (8) { ["errorMessage":"ElephantIO\Exception\ServerConnectionFailureException":private]=> NULL ["message":protected]=> string(70) "An error occurred while trying to establish a connection to the server" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(92) "/var/www/html/shared/socket-io/vendor/wisembly/elephant.io/src/Engine/SocketIO/Version1X.php" ["line":protected]=> int(187) ["trace":"Exception":private]=> array(3) { [0]=> array(6) { ["file"]=> string(92) "/var/www/html/shared/socket-io/vendor/wisembly/elephant.io/src/Engine/SocketIO/Version1X.php" ["line"]=> int(48) ["function"]=> string(9) "handshake" ["class"]=> string(36) "ElephantIO\Engine\SocketIO\Version1X" ["type"]=> string(2) "->" ["args"]=> array(0) { } } [1]=> array(6) { ["file"]=> string(73) "/var/www/html/shared/socket-io/vendor/wisembly/elephant.io/src/Client.php" ["line"]=> int(60) ["function"]=> string(7) "connect" ["class"]=> string(36) "ElephantIO\Engine\SocketIO\Version1X" ["type"]=> string(2) "->" ["args"]=> array(0) { } } [2]=> array(6) { ["file"]=> string(32) "/var/www/html/dashboard/news.php" ["line"]=> int(98) ["function"]=> string(10) "initialize" ["class"]=> string(17) "ElephantIO\Client" ["type"]=> string(2) "->" ["args"]=> array(0) { } } } ["previous":"Exception":private]=> NULL }
I am using Version2X but why am I getting error about Version1X?
I have the same error...
Do you also have the result of getErrorMessage() to null ?
Yes, I have
Which version are you using ? dev-master or 3.1 ?
Sorry, meant 3.3
"wisembly/elephant.io": "^3.3",
Could you then try with dev-master ? I'll try to do a release when I'll have enough time to do it...
And if that doesn't work, could you remove the @ on https://github.com/Wisembly/elephant.io/blob/master/src/Engine/SocketIO/Version1X.php#L196 ?
dev-master is not working

OK now that is strange. It seems that the resource is already busy with something else (probably socket.io ?).
Could you maybe try a ping on that adress / resource ?
BTW, not really sure but your uri looks strange (it shouldn't be escaped : use_b64=0&EIO=...) but maybe it's the error message that does that.
yes, the error message does that
I try the same code on the server (DO) and it's working. But I have the error on my local machine (mac os).
Got no clue then on why this happens, especially as I don't have a mac. Sorry :/
Thanks anyway and good luck!
I change the socket IO server dependencies and it's worked successfully.
It can look at the PR #186 to know more details.
Wow, I have found my mistake!
The trouble in ini_set("default_socket_timeout", -1);
This line was in another package which uses the elephant.io package.
Thank you guys!
I think we don't let the default_socket_timeout be-1 because this will always try connecting the socket server until the connection is established.
I have the same error. Even more, this error occurred accidentally, I didn't change anything. Everything works fine in localhost, in NodeJS, in browser ... But the real server doesn't accept any connections from PHP Client. It's so weird, I have no clue.
Hii there,
I am facing the same issue in ubuntu with php8. Everything is working fine in nodejs and browser. But not working when emit the event from laravel php.