@@ -184,7 +184,8 @@ private void connectInternal()
184
184
long waitTime = 1000L ;
185
185
boolean isConnected = false ;
186
186
wsSession = null ;
187
- while (attempt < maxRetryAttempts && !isConnected )
187
+ // avoid executing if meeting ended (we are not running) while we were reconnecting
188
+ while (attempt < maxRetryAttempts && !(reconnecting && !isRunning ()) && !isConnected )
188
189
{
189
190
try
190
191
{
@@ -231,7 +232,7 @@ private void connectInternal()
231
232
232
233
private synchronized void reconnect ()
233
234
{
234
- if (reconnecting )
235
+ if (reconnecting && ! isRunning () )
235
236
{
236
237
return ;
237
238
}
@@ -250,7 +251,7 @@ private synchronized void reconnect()
250
251
@ OnWebSocketClose
251
252
public void onClose (int statusCode , String reason )
252
253
{
253
- if (! this . participants . isEmpty ())
254
+ if (isRunning ())
254
255
{
255
256
// let's try to reconnect
256
257
if (!wsSession .isOpen ())
@@ -261,7 +262,7 @@ public void onClose(int statusCode, String reason)
261
262
}
262
263
}
263
264
264
- if (participants != null && ! participants . isEmpty ())
265
+ if (isRunning ())
265
266
{
266
267
logger .error ("Websocket closed: " + statusCode + " reason:" + reason );
267
268
}
@@ -366,7 +367,7 @@ public void onMessage(String msg)
366
367
@ OnWebSocketError
367
368
public void onError (Throwable cause )
368
369
{
369
- if (!ended () && participants != null && ! participants . isEmpty ())
370
+ if (!ended () && isRunning ())
370
371
{
371
372
Statistics .incrementTotalTranscriberSendErrors ();
372
373
logger .error ("Error while streaming audio data to transcription service." , cause );
@@ -414,7 +415,7 @@ public void disconnectParticipant(String participantId, Consumer<Boolean> callba
414
415
415
416
private void disconnectParticipantInternal (String participantId , Consumer <Boolean > callback )
416
417
{
417
- if (ended () && ( participants == null || participants . isEmpty () ))
418
+ if (ended () && ! isRunning ( ))
418
419
{
419
420
callback .accept (true );
420
421
return ;
@@ -514,4 +515,15 @@ public boolean ended()
514
515
{
515
516
return wsSession == null ;
516
517
}
518
+
519
+ /**
520
+ * We consider this websocket transcription running when there are participants.
521
+ * While reconnecting we still have participants. After disconnectParticipantInternal where we clean
522
+ * all participants and close the socket we are no longer running, and we should not try to reconnect.
523
+ * @return true if operational.
524
+ */
525
+ private boolean isRunning ()
526
+ {
527
+ return participants != null && !participants .isEmpty ();
528
+ }
517
529
}
0 commit comments