So, i try to launch a server in wss:// since Tuesday but it doesn't work, today i decide to look WebSocket code and i found why my WebSocket closed directly. This is error code i find:
1002 Unsupported usage of rsv bits without negotiated extension.
VALUE OF RSV1:Opcode: 7, fin: false, length: 69, hasPayload: true, masked: false
My program works with ws:// but not with wss://. I can't understand why tls 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>
The error message is confusing, since
Did you try Chrome or IE10?
You could also try running AutobahnTestsuite against your node server.
The testsuite has a fuzzingclient mode that supports WSS. The testsuite includes extensive wire log reports which might help finding out what happens.
Disclosure: I am original author of Autobahn and work for Tavendo.