Mikhail, this worked for me: In /bin/www
var app = require('../app'); var https = require('https'); var fs = require('fs'); var sslOptions = { key: fs.readFileSync('./ssl/server.key'), cert: fs.readFileSync('./ssl/server.crt'), ca: fs.readFileSync('./ssl/ca.crt'), requestCert: true }; var host = '127.0.0.1'; var port = '3000'; var ws_cfg = { ssl: true, port: port, ssl_key: './ssl/server.key', ssl_cert: './ssl/server.crt', ssl_ca: '../ssl/ca.crt' }; var processRequest = function (req, res) { console.log("Server listening on https://" + host + ":%s", port); }; var secureServer = https.createServer(sslOptions, app).listen(port, function () { console.log("Server listening on https://" + host + ":%s", port); }, processRequest).listen(ws_cfg.port); var ws = require('/usr/local/lib/node_modules/websocket.io'); var WebSocketServer = require('/usr/local/lib/node_modules/websocket.io').Server; var wss = new WebSocketServer({ server: secureServer, autoAcceptConnections: false }); var webSocketServer = ws.attach(secureServer); In js client-side var wsConnection = new WebSocket("wss://localhost:3000"); wsConnection.onopen = function () { alert("I'm the client and I'm listening on an open socket!"); var socketMessageToServer = {}; socketMessageToServer.text = "I'm the client and I'm listening on an established socket!"; // Send an initial message to the server wsConnection.send(JSON.stringify(socketMessageToServer)); }; Here is where I can't make it work: I'd like to receive socketMessageToServer in app.js on server side. How do I do that? Let me know. On Sunday, August 28, 2011 at 11:33:26 PM UTC-7, Mikhail wrote: > > I can't set secure websocket connection using websocket-server and > node.js > > server side > > var ws = require("websocket-server"), > fs = require('fs'); > > var options = { > key: fs.readFileSync(PRIVATE_KEY), > cert: fs.readFileSync(CERTIFICATE) > }; > > // create web server > var server = ws.createServer(options); > server.listen(8000); > ... > client side (google chrome) > > <script language="javascript" type="text/javascript"> > var wsUri = "wss://my_url:8000"; > > > function init() { > websocket = new WebSocket(wsUri); > } > > ... > > window.addEventListener("load", init, false); > </script> > But if I change protocol to ws it works fine (var wsUri = "ws://url: > 8000") > Any ideas? -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. To post to this group, send email to nodejs@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/6cead247-22e1-482f-b7eb-bf2270b85ee1%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.