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

Use user-supplied ThreadFactory to create internal Server/Client threads #888

Open
offbynull opened this issue May 9, 2019 · 0 comments

Comments

Projects
None yet
2 participants
@offbynull
Copy link

commented May 9, 2019

Is your feature request related to a problem? Please describe.
This library prevents the application from shutting down when the main application thread ends. The threads launched by the library are what prevent it from shutting down: if they aren't explicitly closed, the process doesn't end.

Describe the solution you'd like
Either allow the user to pass through a daemonize flag for threads spawned by the library or allow the user to supply a ThreadFactory that the library can use to spawn threads.

Describe alternatives you've considered
Using my own Thread to launch a server works fine...

        Thread serverThread = new Thread(server);
        serverThread.setName("WebSocket Server Thread");
        serverThread.setDaemon(true);
        serverThread.start();

But there is no equivalent for clients...

        WebSocketClient client = new Client(new URI("ws://localhost:8887"));
        Thread clientThread = new Thread(client);
        clientThread.setName("WebSocket Server Thread");
        clientThread.setDaemon(true);
        clientThread.start();
        client.sendPing();    // ERRORS OUT
        client.closeBlocking();
        clientThread.join(5000);

Additional context
N/A

@marci4 marci4 added Discussion Server Client and removed Server labels May 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.