How to set secure websocket connection using websocket-server and node.js
NickName:Mikhail.Mamaev Ask DateTime:2011-08-27T02:49:23

How to set secure websocket connection using websocket-server and node.js

I can't set secure websocket connection using websocket-server and node.js

server side

var options = {
    key: fs.readFileSync(PRIVATE_KEY),
    cert: fs.readFileSync(CERTIFICATE)
};

// create web server
var server = ws.createServer(options);
server.listen(8000);
...

client side

<script language="javascript" type="text/javascript">
    var wsUri = "wss://url:8000";


    function init() {            
        websocket = new WebSocket(wsUri);
    }

    ...

    window.addEventListener("load", init, false);
</script>

But it works for ws

var wsUri = "ws://url:8000";

Any ideas?

Copyright Notice:Content Author:「Mikhail.Mamaev」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/7209243/how-to-set-secure-websocket-connection-using-websocket-server-and-node-js

More about “How to set secure websocket connection using websocket-server and node.js” related questions

How to set secure websocket connection using websocket-server and node.js

I can't set secure websocket connection using websocket-server and node.js server side var options = { key: fs.readFileSync(PRIVATE_KEY), cert: fs.readFileSync(CERTIFICATE) }; // create ...

Show Detail

websocket-server replacement in BrowserQuest

I am trying to get Mozilla's BrowserQuest up and running and have run into a problem. It depends on the websocket-server node package, and unfortunately that has been deprecated and removed from t...

Show Detail

Node.js connection error, missing property?

EDIT Solution: Visit your IP in the browser after you "node server.js" to kick-start the connections. Dunno why it works, but it does for me. How it came to be Mkay.. after making a rebuild of ...

Show Detail

Node.js & Socket.io: Self-signed certificates for a secure websocket connection

I've been running across the internet looking for a straight forward answer, but most solutions involve using Express and serving HTTP content for secure connections. I'm more interested in a secur...

Show Detail

pip cannot install websocket-server python packge

I am inside my docker container, which is running centos6.6.1, and cannot seem to install the python package websocket-server. pip install websocket-server Could not find a version that satisfie...

Show Detail

How can I force a secure websocket connection with vapor swift?

I have a websocket server set up with vapor swift. Now I want to force the connection to use the websocket secure protocol from the server side. It's not enough to use a URL like wss://url:8080 bec...

Show Detail

How to setup WebSocket Secure connection with PHP?

I can't find any information about setting up a wss connection in PHP. I have no problem to be connected throw ws. I'm using this pretty great library to do this by the way: https://github.com/albe...

Show Detail

How to Configure WebSocket Server to Accept Secure Connection Request

Before applying ssl(I take from cloudflare) my website is loaded over http and my socket connection is made over ws and it's working fine and connection was made successfully. conn = new WebSock...

Show Detail

Node.js Websocket Using Windows Credentials

I am attempting to create a secure websocket connection to a server that uses self-signed SSL certificates. I have added them to my windows machine as trusted certificates, but when I run the node....

Show Detail

Websocket Connection using CURL

Had a question about how to use CURL to initiate a WebSocket connection to a server to read from it. Been referring to the below: curl --include \ --no-buffer \ --header &quot;Connection:

Show Detail