varspool / Wrench

A simple PHP WebSocket implementation for PHP 7.1
Do What The F*ck You Want To Public License
596 stars 210 forks source link

Getting SSL_R_NO_SHARED_CIPHER when trying to use WSS protocol #127

Closed arTec-Berlin closed 4 years ago

arTec-Berlin commented 4 years ago

First of all thank you for this nice library which works quite well and was easy to use. Running a WebSocketServer via the WS protocol works fine but when we try to switch to wss we get:

PHP Warning: stream_socket_accept(): SSL_R_NO_SHARED_CIPHER: no suitable shared cipher could be used. This could be because the server is missing an SSL certificate (local_cert context option) in /var/www/clients/client8/web47/web/vscout_2.0/WebSocketServer/vendor/wrench/wrench/lib/Socket/ServerSocket.php on line 60

Do you know this problem? Can you help?

Best Martin

arTec-Berlin commented 4 years ago

We got it working after we switched to a real certificate. self signed did not work. After that we just added the .pem file to the server options

nexen2 commented 4 years ago

If you want you use custom cert file, you can use Nginx / Apache as proxy. Very useful in case you are using both HTTP and WS on same host.

For Nginx I use this virtual host settings: location /websocket { proxy_pass http://localhost:8010; proxy_http_version 1.1; proxy_set_header Upgrade \$http_upgrade; proxy_set_header Connection \$connection_upgrade; }

This must be added to nginx general configuration (like /etc/nginx/conf.d/http.conf):

Adjust proxy for websocket server

proxy_read_timeout 600s; map $http_upgrade $connection_upgrade { default upgrade; '' close; }

Then I connect my browser-side WS client to URI wss:///websocket.