elephant.io icon indicating copy to clipboard operation
elephant.io copied to clipboard

Connection Error

Open mmt78 opened this issue 6 years ago • 22 comments

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.

mmt78 avatar Dec 18 '18 18:12 mmt78

Please catch the exception and dump the content of getErrorMessage().

Taluu avatar Dec 19 '18 03:12 Taluu

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?

mmt78 avatar Dec 19 '18 05:12 mmt78

I have the same error...

indigoram89old avatar Apr 05 '19 14:04 indigoram89old

Do you also have the result of getErrorMessage() to null ?

Taluu avatar Apr 05 '19 14:04 Taluu

Yes, I have

indigoram89old avatar Apr 05 '19 14:04 indigoram89old

Which version are you using ? dev-master or 3.1 ?

Taluu avatar Apr 05 '19 14:04 Taluu

Sorry, meant 3.3

Taluu avatar Apr 05 '19 15:04 Taluu

"wisembly/elephant.io": "^3.3",

indigoram89old avatar Apr 05 '19 15:04 indigoram89old

Could you then try with dev-master ? I'll try to do a release when I'll have enough time to do it...

Taluu avatar Apr 05 '19 15:04 Taluu

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 ?

Taluu avatar Apr 05 '19 15:04 Taluu

dev-master is not working

indigoram89old avatar Apr 05 '19 15:04 indigoram89old

img-2019-04-05-18-04-53

indigoram89old avatar Apr 05 '19 15:04 indigoram89old

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.

Taluu avatar Apr 05 '19 15:04 Taluu

yes, the error message does that

indigoram89old avatar Apr 05 '19 15:04 indigoram89old

I try the same code on the server (DO) and it's working. But I have the error on my local machine (mac os).

indigoram89old avatar Apr 05 '19 15:04 indigoram89old

Got no clue then on why this happens, especially as I don't have a mac. Sorry :/

Taluu avatar Apr 05 '19 15:04 Taluu

Thanks anyway and good luck!

indigoram89old avatar Apr 05 '19 15:04 indigoram89old

I change the socket IO server dependencies and it's worked successfully.

It can look at the PR #186 to know more details.

peter279k avatar Apr 10 '19 11:04 peter279k

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!

indigoram89old avatar Apr 10 '19 12:04 indigoram89old

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.

peter279k avatar Apr 10 '19 15:04 peter279k

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.

daryn-k avatar Oct 03 '21 16:10 daryn-k

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.

akshayb007 avatar Mar 25 '22 14:03 akshayb007