Skip to content

Commit

Permalink
Passing the ws subprotocol in the browser.
Browse files Browse the repository at this point in the history
Fixes #251.
  • Loading branch information
mcollina committed Feb 15, 2015
1 parent 0f3db06 commit 6733264
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/connect/ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function buildBuilderBrowser(mqttClient, opts) {
, port = opts.port
, url = opts.protocol + '://' + host + ':' + opts.port

return websocket(url);
return websocket(url, 'mqttv3.1');
}

if (process.title !== 'browser') {
Expand Down
6 changes: 5 additions & 1 deletion test/browser/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ function start(port, done) {
var wss = new WebSocketServer({server: server});

wss.on('connection', function(ws) {
if (ws.protocol !== 'mqttv3.1') {
return ws.end();
}

var stream = websocket(ws);
var connection = new Connection(stream);
handleClient(connection);
Expand All @@ -120,6 +124,6 @@ if (require.main === module) {
console.error(err);
return;
}
console.log('tunnelled server started on port', port);
console.log('tunnelled server started on port', process.env.PORT || process.env.ZUUL_PORT);
});
}

0 comments on commit 6733264

Please sign in to comment.