Answer the question
In order to leave comments, you need to log in
How to set up WebSocket on a self-written SSL certificate (HTTPS)?
I've been dealing with this problem for a week now! Very urgent!
Everything works fine on http, but when I switch to https, it does not connect to the socket server.
The certificate is self-written, created in ispmanager.
Connection code:
var socket = new WebSocket("wss://ixbh.com:8888/server.php");
$context = stream_context_create();
stream_context_set_option($context, 'ssl', 'local_cert', 'ssl.crt/server.pem');
stream_context_set_option($context, 'ssl', 'allow_self_signed', true);
stream_context_set_option($context, 'ssl', 'verify_peer', false);
$socket = stream_socket_server("ssl://0.0.0.0:8888", $errno, $errstr, STREAM_SERVER_BIND|STREAM_SERVER_LISTEN, $context);
while(true){
....
if (in_array($socket, $read)) {
//При попытке соединится, код доходит сюда
if (($connect = stream_socket_accept($socket, -1)) && $info = handshake($connect)) {
//сюда код уже не доходит
$connects[] = $connect;
}
unset($read[array_search($socket, $read)]);
}
....
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question