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

How to properly close the WebSocketClient@ thread problem? #11252

Open
cuideyu opened this issue Jan 8, 2024 · 2 comments
Open

How to properly close the WebSocketClient@ thread problem? #11252

cuideyu opened this issue Jan 8, 2024 · 2 comments
Labels

Comments

@cuideyu
Copy link

cuideyu commented Jan 8, 2024

Jetty Version
Jetty 9.4.53

Jetty Environment
linux
jetty run command: ./bin/jetty.sh run

Java Version
1.8.0_371 x64

Question
I used this code to create a Websocket client connection

WebSocketContainer container = ContainerProvider.getWebSocketContainer();
container.connectToServer(this, URI.create(url));

If the server connection fails, this code will continue to be used during the reconnection.
But each execution of this code creates eight threads of WebSocketClient@xxx-xxx
The connection pool cannot be automatically destroyed if the connection fails.
My code ContainerProvider.getWebSocketContainer();
-> org.eclipse.jetty.websocket.jsr356.ClientContainer<111 line> - > public ClientContainer()
-> WebSocketClient <95 line>-> public WebSocketClient()
-> DefaultHttpClientProvider.get
-> DefaultHttpClientProvider.newHttpClient

Reconnecting will create a new thread pool and 8 threads. How do I close this object? Can't you create a Websocket client this way in Jetty?

image_2024-01-09_01-27-57
@joakime
Copy link
Contributor

joakime commented Jan 8, 2024

Jetty versions older than Jetty 12 are now at End of Community Support.

You should be using Jetty 12 at this point in time.

The WebSocket layer has been reworked entirely for Jetty 12 as well.

@joakime
Copy link
Contributor

joakime commented Jan 8, 2024

See also #2659 (comment)

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

No branches or pull requests

2 participants