@@ -15,6 +15,7 @@ class WSConnector extends Thread {
15
15
private String token ;
16
16
private String address ;
17
17
private int waitPeriod ;
18
+ private int retryWhenNoResponse ;
18
19
// Flags
19
20
private boolean isRunning ;
20
21
private boolean isConnected ;
@@ -41,6 +42,7 @@ public WSConnector(String username, String token, String address,
41
42
this .waitPeriod = framerate > 0 ? ((int ) (1000 / framerate )) : 1 ;
42
43
this .isConnected = false ;
43
44
this .isRunning = false ;
45
+ this .retryWhenNoResponse = 10 ;
44
46
}
45
47
46
48
private boolean gotValidHttpCode () {
@@ -219,6 +221,8 @@ public void run() {
219
221
220
222
JhFrameObject frame = JhFrameObject .getEmptyFrame ();
221
223
224
+ int retry = retryWhenNoResponse ;
225
+
222
226
// Main loop
223
227
while (this .isRunning && this .isConnected ) {
224
228
setStatus (WSCStatus .RUNNING );
@@ -252,8 +256,15 @@ public void run() {
252
256
framesDisplayed ++;
253
257
254
258
if (ws .millisSinceResponse () > (500 + 2 * waitPeriod )) {
255
- System .err .println ("Error: Server not responding! Please check your network connection." );
256
- this .isRunning = false ;
259
+ if (retry < 1 ) {
260
+ System .err .println ("Error: Server not responding! Please check your network connection." );
261
+ this .isRunning = false ;
262
+ } else {
263
+ retry --;
264
+ System .err .println ("Error: Server not responding! Retrying ..." );
265
+ }
266
+ } else {
267
+ retry = retryWhenNoResponse ;
257
268
}
258
269
259
270
// 3. Sleep depending on framerate, with small negative offset.
0 commit comments