简体   繁体   中英

Websocket ERR_SSL_PROTOCOL_ERROR over https

I am using PHP at server side and APACHE webserver

If I use secure web socket protocol over HTTPS:

At client side I am using Javascript to connect websocket. Folllowing is the code `

var wsUri = wss://mywebsite.com:8012/test/web-socket    
    websocket = new WebSocket(wsUri); 

    websocket.onopen = function(ev) { // connection is open 
        $('#message_box').append("<div class=\"system_msg\">Connected!</div>"); //notify user
}`

I receive an error on establishing connection net::ERR_SSL_PROTOCOL_ERROR

Same is working with http

I have resolved this by provided certificate & key compbined file to stream_context_set_option function. That resolved ssl_protocol_error.

$context = stream_context_create();         
stream_context_set_option($context, 'ssl', 'local_cert', '/tmp/combined_cert.pem');         
stream_context_set_option($context, 'ssl', 'passphrase', '');           
stream_context_set_option($context, 'ssl', 'allow_self_signed', true);          
stream_context_set_option($context, 'ssl', 'verify_peer', false);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM