austgl / phpws

Automatically exported from code.google.com/p/phpws
0 stars 0 forks source link

About SSL Connection #33

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
In an environment without SSL,  phpws works fine.
When I try to add SSL to both server and client(below)

Server Side*********************************************

    public function __construct() {
        $this->server = new WebSocketServer("ssl://bobo.greedio.com:8089", 'superdupersecretkey');
        $this->server->addObserver($this);
        $this->server->addUriHandler("echo", new DemoEchoHandler());        
    $this->setupSSL();
    }

    public function setupSSL() {
        $context = stream_context_create();

        // local_cert must be in PEM format
        stream_context_set_option($context, 'ssl', 'local_cert', './greedio.pem');
        stream_context_set_option($context, 'ssl', 'allow_self_signed', true);
        stream_context_set_option($context, 'ssl', 'verify_peer', false);

        $this->server->setStreamContext($context);
    }

Client Side************************************************

function init() {
                var host = "wss://bobo.greedio.com:8089/client";
                try {
                    socket = new WebSocket(host);
                    log('WebSocket - status ' + socket.readyState);
                    socket.onopen = function(msg) {
                        log("Welcome - status " + this.readyState);
                    };
  ........

}

Client-side immediately disconnect without any error message.
You can try it on https://bobo.greedio.com/phpws/client.html

Later, I wrote a Windows program and try to connect (with ssl), but can be 
wired normally.

Someone help?

Original issue reported on code.google.com by Eric.Che...@gmail.com on 30 Jun 2013 at 2:30

GoogleCodeExporter commented 9 years ago
Same happens to me :( I am looking for a SSL Websocket in PHP too

Original comment by pedrocan...@gmail.com on 9 Feb 2014 at 1:19