Skip to content

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

Description

@offbynull

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions