Answer the question
In order to leave comments, you need to log in
How to release port in NodeJS after websocket disconnect?
How to release port in NodeJS after websocket disconnect?
WS module
https://www.npmjs.com/package/ws
I create a client on the server
var WebSocket = require('ws');
var ws = new WebSocket('ws://www.host.com:13310');
ws.on('open', function open() {
ws.send('something');
});
ws.on('message', function(data, flags) {
// flags.binary will be set if a binary data is received.
// flags.masked will be set if the data was masked.
});
var adsadas = setTimeout(function() {
var ws = new WebSocket('ws://127.0.0.1:8778');
ws.on('open', function open() {
ws.send('something');
});
ws.on('message', function(data, flags) {
// flags.binary will be set if a binary data is received.
// flags.masked will be set if the data was masked.
});
}, 10000);
events.js:154
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED 127.0.0.1:8778
at Object.exports._errnoException (util.js:856:11)
at exports._exceptionWithHostPort (util.js:879:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1062:14)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question