Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process is hanging after calling client.close #148

Open
Rinse12 opened this issue Nov 5, 2023 · 3 comments
Open

process is hanging after calling client.close #148

Rinse12 opened this issue Nov 5, 2023 · 3 comments

Comments

@Rinse12
Copy link

Rinse12 commented Nov 5, 2023

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");
@mkozjak
Copy link
Member

mkozjak commented Nov 13, 2023

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");
})

@Rinse12
Copy link
Author

Rinse12 commented Nov 13, 2023

In the case the connection never gets established, I believe the process will be still hanging (if I remember correctly)

@mkozjak
Copy link
Member

mkozjak commented Nov 13, 2023

Please test if you get either the error or close event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants