Skip to content

Commit

Permalink
fix(iot-dev): map SocketTimeoutException to be retryable
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmineymlo committed Jul 16, 2018
1 parent d79f860 commit 0a21df8
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.eclipse.paho.client.mqttv3.MqttException;

import java.net.NoRouteToHostException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;

import static org.eclipse.paho.client.mqttv3.MqttException.*;
Expand All @@ -28,9 +29,12 @@ public static ProtocolException convertToMqttException(MqttException pahoExcepti
// for this connection loss is in the mqttException cause
if (pahoException.getCause() instanceof UnknownHostException
|| pahoException.getCause() instanceof NoRouteToHostException
|| pahoException.getCause() instanceof InterruptedException)
|| pahoException.getCause() instanceof InterruptedException
|| pahoException.getCause() instanceof SocketTimeoutException)
{
//Codes_SRS_PahoExceptionTranslator_34_139: [When deriving the TransportException from the provided MqttException, this function shall map all client exceptions with underlying UnknownHostException or InterruptedException to a retryable ProtocolException.]
// Codes_SRS_PahoExceptionTranslator_34_139: [When deriving the TransportException from the provided
// MqttException, this function shall map all client exceptions with underlying UnknownHostException
// or InterruptedException or SocketTimeoutException to a retryable ProtocolException.]
ProtocolException connectionException = new ProtocolException(errorMessage, pahoException);
connectionException.setRetryable(true);
return connectionException;
Expand Down

0 comments on commit 0a21df8

Please sign in to comment.