ghedipunk / PHP-Websockets

A Websockets server written in PHP.
BSD 3-Clause "New" or "Revised" License
917 stars 374 forks source link

How run it with SSL [wss] #74

Closed johnson1823 closed 8 years ago

johnson1823 commented 8 years ago

Hey, I have server VPS with debian 6. I have installed PHP 5.6 with module openssl and I can't connect to the server with wss://. Do you know why ? Server respond timeout, but ws:// run.

ghedipunk commented 8 years ago

TLS is not currently implemented in the Master branch.

It is implemented in the Legacy branch, though. See: https://github.com/ghedipunk/PHP-Websockets/tree/legacy

As it is currently implemented, you will need to run two separate instances of the server if you want to have both WS and WSS running at the same time. Also note that you should have two separate instances of any server running, to help prevent leaking secure data over an insecure connection.

Closing as a "wontfix" as there is already active development on the new development branches that will have TLS support, and the legacy branch provides a mostly compatible alternative to the master branch. Thus there will be no code changes specific to this issue.

If you need more support, please feel free to continue to comment here despite the issue being closed.

amaretto4u commented 8 years ago

It's better to use apache or nginx to handle ssl connections and forward it to websockets Way to forward connection thought nginx :

upstream websocket {
    server 127.0.0.1:8001;
}
server {
   ...
   location /socket {
        proxy_pass http://websocket;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_read_timeout 600s;
    }
   ...
}

change 8001 to your port

johnson1823 commented 8 years ago

Ghedipunk I use it and configure, but I heve error: failed: Error during WebSocket handshake: Unexpected response code: 405

jeancaffou commented 4 years ago

@amaretto4u wouldn't this put unnecessary strain on the webserver, specifically the MaxClients directive?

amaretto4u commented 4 years ago

I think it depends on active user count, but i don't have problem on my setups. I use this combination more than 2 years. Don't have any notable difference in memory or CPU consumption if i turn it on or off.

jeancaffou commented 4 years ago

How many peak active users?

amaretto4u commented 4 years ago

host have ~100 domains ~700 peak active connections ~100 of them with web sockets