rpc-websockets
rpc-websockets copied to clipboard
process is hanging after calling client.close
Thank you for open sourcing this library. We're having this issue where the process is not exiting after stopping the client. We're on 7.6.0. This code should replicate the problem:
const WebSocket = require("rpc-websockets").Client;
const client = new WebSocket("ws://localhost:39652");
client.close();
console.log("Program should exit after this");
Hey, thanks!
The clients polls for connection with new WebSocket
first and then issues the 'open' event afterwards. You can use close
right after. What's the use-case for this, though?
It works like this:
var WebSocket = require('rpc-websockets').Client
const client = new WebSocket("ws://localhost:39652");
client.on('open', function() {
console.log('socket opened')
client.close();
console.log("Program should exit after this");
})
In the case the connection never gets established, I believe the process will be still hanging (if I remember correctly)
Please test if you get either the error
or close
event.