PHP Websocket not working with WSS

i need to use ssl with websocket but still not working, its work only with WS. For WSS i receive ‘TCP connection lost’ error

nginx version 1.2.1

Server started
Listening on:
Master socket: Resource id #6
Client connected. Resource id #7
Client disconnected. TCP connection lost: Resource id #7

Nginx config (i have already test upstream but not work)

server {
        listen 80;
        listen   443 ssl;

        root /;
        index index.php index.html index.htm;


        location / {
                try_files $uri $uri/ /index.html;
                disable_symlinks off;


        location /ws/ {
            proxy_http_version 1.1;
            proxy_set_header Host $host;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_read_timeout 86400;

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;


        ssl on;
        ssl_certificate example_com.pem;
        ssl_certificate_key example_com.key;

        ssl_session_timeout 5m;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;


Client javascript

new WebSocket('wss://');

Php (websocket class link

#!/usr/bin/env php

class echoServer extends WebSocketServer {
  protected function process ($user, $exec) {

  protected function connected ($user) {

  protected function closed ($user) {

$echo = new echoServer("","11011");

try {
catch (Exception $e) {

Why my configuration work only without ssl ? my certificate is correctly installed

Thanks you


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s