Error While Trying To Establish a Connection on SSL HTTPS
Hello Good Day!
I have a problem establishing a connection server with my ssl certificate.
"An error occurred while trying to establish a connection to the server"
I have this code :
$this->client = new Client(new Version1X("https://www.sockettestserver.com:3000"));
And now I checked one of the tickets here like passing this $options:
$options = [
'context' => [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false
]
]
];
$this->client = new Client(new Version1X("https://www.sockettestserver.com:3000", $options));
But still I can't establish any connection.
If I am sending an http request it is working and it listens to port 3000 just fine. But when I changed the connection to https I am getting that error.
Hope you can help me.
Thanks is advance.
As said in https://github.com/Wisembly/elephant.io/issues/179#issuecomment-448460882, please catch the exception and dump the getErrorMessage().
It should pinpoint you the error on why it couldn't connect your to the server.
BTW, IIUC, you are trying to make a ssl connection on a insecured port. Don't you have another port that is open for ssl ?
I am using port 443 for the ssl connection. Should I try using it instead of port 3000?
Is this also maybe one of the reason i cant make a connection?
Probably, give it a try. :}
Okay Thanks. I am really new to sockets and ssl connections. I will give it try and give you a feedback.
Hello @Taluu , I tried using port 443, Here's what i got " This server does not support the websocket transport, aborting ", Is this a problem on my node server or the elephant io itself?
Thank you
AFAIK, I think it's a problem on your node server. I think you're serving through http (not https) on the port 3000, and the port 443 is not listened by your node server but your http server (which can be different).
You also cannot (AFAIK) serve both secured and unsecured connections on the same port. So you should configure your node server to deliver a https connection on another port (or through the 3000).
I run into this issue, solved by : https://www.php.net/manual/fr/function.stream-context-create.php#74795 and https://www.php.net/manual/fr/context.http.php#121763
Must use context "http" not "ssl" in wisembly/elephant.io/src/Engine/SocketIO/Version1X.php line 165
$protocol = true === $this->url['secured'] ? 'http' : 'http';
Care to make a PR ?
yes... I'll try later but with a proper code because because this lines is useless $protocol = true === $this->url['secured'] ? 'http' : 'http'; same as : $protocol = 'http'
yes, but not in 3.3.1 My fault... https://github.com/Wisembly/elephant.io/blob/v3.3.1/src/Engine/SocketIO/Version1X.php
Yep just saw, that's why I deleted my comment. :}
I think there was an error at some point that needed the ssl context for ssl connections instead of https, but using the https:// protocol should be fine (with ssl context if you need some certificates).
Socket connect is ok (+ HEADERS working) in dev-master But emit not working (write function ?) Seems to be the same problem... I fall back to 3.3.1 and change only Version1X.php line 165
I'll try to investigate later...
@lorenzyannick any news in your investigation? I have the same error
After passing $context parameter I fixed my situation.
$options = [
'context' => [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false
]
]
];
$this->client = new Client(new Version1X("https://www.sockettestserver.com:3000", $options));
I'm having the same issue, the options you provide @daryn-k works. But why suddenly this issue?