PHP Websocket client + ssl -


there php websocket client: https://github.com/symbiose/php-websocket-client repository. , works fine not-secured connection.

what need connect websocket server php code through secure connection. implement task took code above , modified bit. connect() method of websocketclient looks in code:

public function connect() {     $root = $this;     if ($this->getport() == 443) {       $context = stream_context_create();       stream_context_set_option($context, 'ssl', 'allow_self_signed', true);       stream_context_set_option($context, 'ssl', 'verify_peer', false);       $client = stream_socket_client("tls://{$this->gethost()}:{$this->getport()}", $errno, $errstr, 30, stream_client_connect, $context);     } else {       $client = stream_socket_client("tcp://{$this->gethost()}:{$this->getport()}", $errno, $errstr);     }     if (!$client) {         throw new runtimeexception('cannot connect socket ([#'.$errno.'] '.$errstr.')');     }     $this->setsocket(new connection($client, $this->getloop()));     $this->getsocket()->on('data', function ($data) use ($root) {         $data = $root->parseincomingraw($data);         $root->parsedata($data);     });     $this->getsocket()->write($this->createheader());     return $this; } 

as result managed connect server. websocket server saw connection, replied ok , wrote log.

but unfortunately, library doesn't understand, has connected server.

this "if":

    if (base64_encode(pack('h*', sha1($this->key . '258eafa5-e914-47da-95ca-c5ab0dc85b11'))) === $response['sec-websocket-accept']) {         $this->connected = true;     }  

never gets executed. , can't establish connection.

i can confirm, if use 80 port - works charm.

so if have ideas on why can happen, i"d really appreciate them. cause i've ran out of ideas.

best regards, kostya


Comments

Popular posts from this blog

Error while updating a record in APEX screen -

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

ios - Xcode 5 "No such file or directory" -