I tried to launch a server in wss:// last Tuesday, but it didn't work. Today I decided to look at the WebSocket code and I found why my WebSocket closed directly. This is error code I found:
1002 Unsupported usage of rsv bits without negotiated extension.VALUE OF RSV1:Opcode: 7, fin: false, length: 69, hasPayload: true, masked: falseMy program works with ws:// but not with wss://. I can't understand why TLS is blocked.
I precise IPtables are stopped and my certificate is OK.
Do you have any idea?
Below is my code if you want to look:
var fs = require('fs');var https = require('https');var WebSocketServer = require('websocket').server;var express = require('express');var serverTLS = express.createServer({ key: fs.readFileSync(__dirname +'/notification_mail/notification.mail.com.key'), cert: fs.readFileSync(__dirname +'/notification_mail/notification.mail.com.crt')});serverTLS.configure(function(){ serverTLS.set('views',__dirname); serverTLS.set('view engine','ejs');});serverTLS.get('/',function(req,res){ res.render('index',{layout: false });});serverTLS.listen("443");var wss = new WebSocketServer({ httpServer: serverTLS, autoAcceptConnections: true });wss.on('connect', function(connection) { console.log((new Date()) +" Connection accepted."); connection.on('close', function(connection) { console.log((new Date()) +" Disconnected"); });});console.log("Server launch");And my HTML file
<html><head><meta charset="utf-8"><title>Example</title></head><body><h1>Serveur 2</h1><div id="tchat"></div><script> var url = "wss://notification.mail.com"; var wsCtor = window['MozWebSocket'] ? MozWebSocket : WebSocket; this.socket = new wsCtor(url, 'connect'); this.socket.onclose = function(){ alert ("Connection lost"); }</script></body></html>