Refactor blitzortung reconnect logic
This commit is contained in:
parent
6bfc57f114
commit
f54da5f702
2 changed files with 6 additions and 7 deletions
|
|
@ -39,15 +39,17 @@ public class BlitzortungProvider extends ThunderProvider {
|
|||
|
||||
scheduledExecutorService.schedule(() -> {
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
websocketClient.closeBlocking();
|
||||
|
||||
Thread.sleep(3000);
|
||||
submitEvent("Reconnecting");
|
||||
websocketClient.reconnectBlocking();
|
||||
websocketClient.connectBlocking();
|
||||
} catch (InterruptedException e) {
|
||||
submitEvent("Failed to reconnect", e);
|
||||
}
|
||||
}, 5, TimeUnit.SECONDS);
|
||||
|
||||
submitEvent("Reconnecting in 5 seconds");
|
||||
submitEvent("Reconnecting in 3 seconds");
|
||||
}
|
||||
|
||||
void submitStrike(Coordinates coordinates, long timestamp) {
|
||||
|
|
|
|||
|
|
@ -77,9 +77,7 @@ class BlitzortungWebsocketClient extends WebSocketClient {
|
|||
blitzortungProvider.submitStrike(coordinates, time);
|
||||
} catch (JsonParseException e) {
|
||||
blitzortungProvider.wsSubmitEvent("Websocket received invalid JSON", e);
|
||||
// ignore invalid json
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -94,8 +92,7 @@ class BlitzortungWebsocketClient extends WebSocketClient {
|
|||
public void onError(Exception ex) {
|
||||
blitzortungProvider.wsSubmitEvent("Websocket error", ex);
|
||||
|
||||
this.uri = uris[++currentUri % uris.length];
|
||||
blitzortungProvider.reconnect();
|
||||
closeConnection(0, "Closed because of an error");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue