@@ -233,7 +233,7 @@ public void onFailure(@NotNull WebSocket webSocket, @NotNull Throwable t, @Nulla
233233 LOGGER .error ("Trying to open a new connection in same wsocket: " , t );
234234 WebsocketStreamClientImpl .this .onClose (webSocket , 0 , "Socket Exception caused by server" );
235235 }
236- reconnect ();
236+ connect ();
237237 }
238238
239239 @ Override
@@ -293,7 +293,8 @@ public void onError(WebSocket webSocket, Throwable t) {
293293 @ Override
294294 public void onClose (WebSocket ws , int code , String reason ) {
295295 LOGGER .info ("WebSocket closed. Code: {}, Reason: {}" , code , reason );
296- ws .close (code , reason );
296+ // cancel, since we're having problems using close (it's wait for graceful shutdown)
297+ ws .cancel ();
297298 this .webSocket = null ;
298299 }
299300
@@ -327,27 +328,6 @@ public WebSocket connect() {
327328 return this .webSocket ;
328329 }
329330
330- private synchronized void reconnect () {
331- try {
332- // Reconnect to the same stream
333- if (requiresAuthentication (path )) {
334- if (path .equals (BybitApiConfig .V5_TRADE ) && params != null ) {
335- getTradeChannelStream (params , path );
336- } else if (argNames != null ) {
337- getPrivateChannelStream (argNames , path );
338- }
339- } else {
340- if (argNames != null ) {
341- getPublicChannelStream (argNames , path );
342- } else {
343- LOGGER .warn ("No args provided for public stream. Cannot reconnect." );
344- }
345- }
346- } catch (Exception e ) {
347- LOGGER .error ("Reconnect failed" , e );
348- }
349- }
350-
351331 @ Override
352332 public WebSocket getPublicChannelStream (List <String > argNames , String path ) {
353333 setupChannelStream (argNames , path );
0 commit comments