TooTallNate / Java-WebSocket

A barebones WebSocket client and server implementation written in 100% Java.
http://tootallnate.github.io/Java-WebSocket
MIT License
10.47k stars 2.57k forks source link

java.lang.IllegalStateException: WebSocketClient objects are not reuseable #1295

Closed disymayufei closed 1 year ago

disymayufei commented 1 year ago

Describe the bug When I try to reconnect the websocket after the connection unexpected disconnected, the error "java.lang.IllegalStateException: WebSocketClient objects are not reuseable" has occurred. I try to change the thread from main thread to another, but the error still occured.

To Reproduce Steps to reproduce the behavior:

  1. Disconnect the websocket connection.
  2. Call reconnect method in main thread or another thread (not websocket client thread)
  3. The error occured.

Expected behavior The websocket client can be reconnected normally.

Debug log java.lang.IllegalStateException: WebSocketClient objects are not reuseable at org.java_websocket.client.WebSocketClient.connect(WebSocketClient.java:372) at org.java_websocket.client.WebSocketClient.reconnect(WebSocketClient.java:315) ......

Environment(please complete the following information):