on 10-26-2016 5:27 AM
Hello
I am trying the Hana Express tutorials about websockets.
I have followed the explanations, copied the files and built with no error.
But when I run the application, my Websocket connection close immediately (message displayed in pop-up).
Can anyone help ?
Regards
Emmanuel
Hello Emmanuel:
Can you please post any message you are seeing in the console.
Also, can you try modifying the following block:
wss.on("connection", function (ws) {
ws.on("message", function (message) {
console.log("received: %s", message);
wss.broadcast(message);
});
ws.send(JSON.stringify({
user: "XS",
text: "Hello from Node.js XS Server"
}));
});
to include some logging for the open and close methods to see if you were able to open the socket.
wss.on("connection", function (ws) {
ws.on("message", function (message) {
console.log("received: %s", message);
wss.broadcast(message);
});
ws.send(JSON.stringify({
user: "XS",
text: "Hello from Node.js XS Server"
}));
ws.on('open', function open() { console.log('connected') });
ws.on('close', function close() { console.log('disconnected'); });
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.