Fatao Error: ServerConnectionFailureException
Hello sorry i know this will be a basic answer but i've been digging around online for hours and can't find anything to solve it.
I'm getting the follow error:
[17-May-2021 12:21:39 UTC] PHP Fatal error: Uncaught ElephantIO\Exception\ServerConnectionFailureException: An error occurred while trying to establish a connection to the server in /Users/#/html/sockets/vendor/wisembly/elephant.io/src/Engine/SocketIO/Version1X.php:187
Stack trace:
#0 /Users/#/html/sockets/vendor/wisembly/elephant.io/src/Engine/SocketIO/Version1X.php(48): ElephantIO\Engine\SocketIO\Version1X->handshake()
#1 /Users/#/html/sockets/vendor/wisembly/elephant.io/src/Client.php(60): ElephantIO\Engine\SocketIO\Version1X->connect()
#2 /Users/#/html/sockets/emit.php(12): ElephantIO\Client->initialize()
#3 {main}
thrown in /Users/#/html/sockets/vendor/wisembly/elephant.io/src/Engine/SocketIO/Version1X.php on line 187
(filepath removed for privacy)
I did search through existing issues and found something similar at the URL below but it didn't - to me atleast - provide a solution.
https://github.com/Wisembly/elephant.io/issues/179
the code im using to initialize is as follows:
include ("vendor/autoload.php");
use ElephantIO\Client;
use ElephantIO\Engine\SocketIO\Version2X;
$version = new Version2X("http://localhost:3001");
$client = new Client($version);
$client->initialize();
$client->emit("new_order", ["test"=>"test","test1"=>"test1"]);
$client->close();
Any help would be incredibly appreciated.
All the best, Coinstacker Team
Hey,
Just edited your message to have the proper coloration and stuff. :}
To go back onto your problem, which version of socket.io are you using ? As far as I know and can remember, I think this lib is compatible with Socket.io 0.X, 1.X, and 2.X. I know socket.io has released several more versions since then, so not sure if it's not a compatibility problem which is likely.
IIRC, I did a debug possibility (to have more details) if you catch the error. There is a method to have more information I think :
include ("vendor/autoload.php");
use ElephantIO\Client;
use ElephantIO\Engine\SocketIO\Version2X;
try {
$version = new Version2X("http://localhost:3001");
$client = new Client($version);
$client->initialize();
$client->emit("new_order", ["test"=>"test","test1"=>"test1"]);
$client->close();
} catch (ElephantIO\Exception\ServerConnectionFailureException $e) {
echo $e->getErrorMessage();
}
You should have more details on what failed...
Hey,
Just edited your message to have the proper coloration and stuff. :}
To go back onto your problem, which version of socket.io are you using ? As far as I know and can remember, I think this lib is compatible with Socket.io 0.X, 1.X, and 2.X. I know socket.io has released several more versions since then, so not sure if it's not a compatibility problem which is likely.
IIRC, I did a debug possibility (to have more details) if you catch the error. There is a method to have more information I think :
include ("vendor/autoload.php"); use ElephantIO\Client; use ElephantIO\Engine\SocketIO\Version2X; try { $version = new Version2X("http://localhost:3001"); $client = new Client($version); $client->initialize(); $client->emit("new_order", ["test"=>"test","test1"=>"test1"]); $client->close(); } catch (ElephantIO\Exception\ServerConnectionFailureException $e) { echo $e->getErrorMessage(); }You should have more details on what failed...
tried this no error shown