Skip to content

Commit

Permalink
handle 'canConnectViaSocket' for reconnect
Browse files Browse the repository at this point in the history
* Should go to connecting state with MISCONFIGURED status

Signed-off-by: Yannic Klem <yannic.klem@bosch.io>
  • Loading branch information
Yannic92 committed Jul 30, 2021
1 parent 917bf5b commit c030e39
Showing 1 changed file with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,7 @@ private void reconnect() {
} else {
logger.info("Socket is closed, scheduling a reconnect.");
cleanupResourcesForConnection();
throw newConnectionFailedException(DittoHeaders.empty());
}
}

Expand Down Expand Up @@ -1076,7 +1077,14 @@ private FSM.State<BaseClientState, BaseClientData> connectionTimedOut(final Base
logger.info("Connection requires SSH tunnel, start tunnel.");
tunnelActor.tell(SshTunnelActor.TunnelControl.START_TUNNEL, getSender());
} else {
reconnect();
try {
reconnect();
} catch (final ConnectionFailedException e){
return goToConnecting(reconnectTimeoutStrategy.getNextTimeout())
.using(data.setConnectionStatus(ConnectivityStatus.MISCONFIGURED)
.setConnectionStatusDetails(e.getMessage())
.resetSession());
}
}
return goToConnecting(reconnectTimeoutStrategy.getNextTimeout()).using(data.resetSession()
.setConnectionStatus(ConnectivityStatus.FAILED)
Expand Down Expand Up @@ -1114,15 +1122,21 @@ private State<BaseClientState, BaseClientData> connectAfterTunnelStarted(final C

if (data.getSessionSenders().isEmpty()) {
logger.info("Reconnecting after ssh tunnel was established.");
reconnect();
try {
reconnect();
return stay();
} catch (final ConnectionFailedException e){
return goToConnecting(reconnectTimeoutStrategy.getNextTimeout())
.using(data.setConnectionStatus(ConnectivityStatus.MISCONFIGURED)
.setConnectionStatusDetails(e.getMessage())
.resetSession());
}
} else {
logger.info("Connecting initially after tunnel was established.");
final ActorRef sender = data.getSessionSenders().get(0).first();
final DittoHeaders dittoHeaders = data.getSessionSenders().get(0).second();
doOpenConnection(data, sender, dittoHeaders);
return doOpenConnection(data, sender, dittoHeaders);
}

return stay();
}

private State<BaseClientState, BaseClientData> testConnectionAfterTunnelStarted(final Control control,
Expand Down

0 comments on commit c030e39

Please sign in to comment.