Cannot be establish the connection with server
I'm not able to establish a connection to the server using this php client. With the javascript client I usually get it.
An error occurred while trying to establish a connection to the server relates #163 #161 #160
I've been using port 3000 on the server.
Do you have more information ? The exception should be more verbose now.
ping @Taluu
I'm suspecting you should use the Version2X instead of Version1X (as it is told in the tickets you linked). Anyway, more information should be available in the getErrorMessage method of the ServerConnectionFailureException class, which is thrown on this error.
I'm already using the Version2X class and now I've added a try/catch and the getErrorMessage method is returning null.
Which version are you using ? Because the line 190 is not the one throwing the exception on latest tag and master...
Otherwise, could you add a sort of dump of the $error variable just before the exception is thrown ? Thanks.
I'm using the 3.3.1 and I will try with dev-master version
Removing the @ in @file_get_contents... line 177 Version1X.php
I received this warning:
Warning: file_get_contents(http://127.0.0.1:3000/socket.io/?use_b64=0&EIO=3&transport=polling): failed to open stream: Connection refused
Try to access http://127.0.0.1:3000/socket.io/?use_b64=0&EIO=3&transport=polling then http://127.0.0.1:3000/socket.io/?use_b64=0&EIO=3&transport=polling ? In your given uri (in the construct), what is the value of the given url ?
(I think it comes from elephant.io, I'll try to look up if when I'll be getting some time)
The error was not in the lib but in my network. Sorry and thanks for your attention. @Taluu.
Np. But reopening as it brought an error to my attention. :)
I had the same issues. There is more then one pitfall btw. In my case docker container had a wrong port alignment. So: check ports in case of docker (e.g https://server_node:8443) But also a self-asigned tls/ssl can couse trouble. Use this workaround $context = [ 'http' => [ 'method' => 'GET' ], 'ssl' => [ 'verify_peer' => true, 'allow_self_signed'=> true ] ]; @ stream_context_create()
But also your php.ini may need some more flags. Make sure allow_url_fopen is On
This is usually caused by connection errors that gets eaten by the @file_get_contents line. The best would be to handle them instead.
I am getting the same issues. It caused after I switched from http to https @Taluu
try https://github.com/Wisembly/elephant.io/issues/181#issuecomment-580669128
may help you
comment lines 175 ~ 185 in /Engine/SocketIO/Version1X.php
then write this code
$protocol = true === $this->url['secured'] ? 'ssl' : 'http';
if(isset($this->context[$protocol])){
$context = $this->context;
$context['http']=$context[$protocol];
@unset($context['ssl']);
}
$context['http'] = $context['http'] ?? [];
if (isset($this->options['headers'])) {
$headers = $context[$protocol]['header'] ?? [];
$context['http']['header'] = array_merge($headers, $this->options['headers']);
}
if (isset($this->options['ssl'])) {
$ssl = $context[$protocol]['ssl'] ?? [];
$context['ssl'] = array_merge($ssl, $this->options['ssl']);
}
may help you
comment lines
164~174in/Engine/SocketIO/Version1X.phpthen write this code
$protocol = true === $this->url['secured'] ? 'ssl' : 'http'; if(isset($this->context[$protocol])){ $context = $this->context; $context['http']=$context[$protocol]; @unset($context['ssl']); } $context['http'] = $context['http'] ?? []; if (isset($this->options['headers'])) { $headers = $context[$protocol]['header'] ?? []; $context['http']['header'] = array_merge($headers, $this->options['headers']); } if (isset($this->options['ssl'])) { $ssl = $context[$protocol]['ssl'] ?? []; $context['ssl'] = array_merge($ssl, $this->options['ssl']); }
I am using this code. How can I solve the problem?
$client = new Client(new Version2X('https://xxxxx:6001', ['context' => ['ssl' => [ 'verify_peer_name' =>false, 'verify_peer' => false ] ]] ));
https://stackoverflow.com/a/66090819/4690409
What are u even talking about
On Thu, Dec 23, 2021, 2:14 PM burak berktürk @.***> wrote:
https://stackoverflow.com/a/66090819/4690409
— Reply to this email directly, view it on GitHub https://github.com/Wisembly/elephant.io/issues/165#issuecomment-1000526176, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADIIPOSKDDXPJWAVTHXMBHDUSOGKPANCNFSM4EESWODA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you are subscribed to this thread.Message ID: @.***>
I am also facing same issue, I am not sure but I find out that if I connect to server using socket version ^3.0.0 than I am getting connection error but when I am using version ^2.0.0 It is establish connection successfully.
Is there any other library I can use for socket connection with version 3?
Since this package is largely unmaintained as far as I'm aware I've also stopped using it in my own app, and have not found a suitable replacement since.