Reputation: 15093
I have this sample websocket
server in nodejs
test-websocket-server
When I run it it "appears" to have started up.
but when I try using tyrus
(or any other means) websocket client to connect to it i'm stuck in connecting phase:
$ java -jar tyrus-client-cli-1.1.jar ws://localhost:8080/mypath Connecting to ws://localhost:8080/mypath...
it just stays like this in "connecting" phase from what I understand it should get "connected".
source of the app.js
(which also appears in link to github)
var wsServer = require('ws').Server;
var ws = new wsServer({
port: '8080',
path: 'mypath'
});
ws.on('open', function open() {
ws.send('something');
});
ws.on('message', function(data, flags) {
console.log("got message: " + data)
// flags.binary will be set if a binary data is received.
// flags.masked will be set if the data was masked.
});
Upvotes: 0
Views: 543
Reputation: 203231
As per RFC 6455, you need to prefix the path with a /
:
var wss = new wsServer({
port: 8080,
path: '/mypath'
});
Upvotes: 1