Skip to content

Commit 1b04514

Browse files
committed
Delaying retry on send when no connection is found
1 parent 1b7035e commit 1b04514

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

core/src/main/java/com/microsoft/applicationinsights/internal/channel/common/TransmissionNetworkOutput.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.apache.http.HttpResponse;
4444
import org.apache.http.HttpStatus;
4545
import org.apache.http.client.methods.HttpPost;
46+
import org.apache.http.conn.ConnectTimeoutException;
4647
import org.apache.http.conn.ConnectionPoolTimeoutException;
4748
import org.apache.http.entity.ByteArrayEntity;
4849

@@ -63,6 +64,7 @@ public final class TransmissionNetworkOutput implements TransmissionOutput {
6364
private final static String RESPONSE_RETRY_AFTER_DATE_FORMAT = "E, dd MMM yyyy HH:mm:ss";
6465

6566
private final static String DEFAULT_SERVER_URI = "https://dc.services.visualstudio.com/v2/track";
67+
private final static int DEFAULT_BACKOFF_TIME_SECONDS = 300;
6668

6769
// For future use: re-send a failed transmission back to the dispatcher
6870
private TransmissionDispatcher transmissionDispatcher;
@@ -163,6 +165,10 @@ public boolean send(Transmission transmission) {
163165
InternalLogger.INSTANCE.error("Failed to send, wrong host address or cannot reach address due to network issues, exception: %s", e.getMessage());
164166
} catch (IOException ioe) {
165167
InternalLogger.INSTANCE.error("Failed to send, exception: %s", ioe.getMessage());
168+
// backoff retry if no connection is found
169+
if (ioe instanceof ConnectTimeoutException) {
170+
transmissionPolicyManager.suspendInSeconds(TransmissionPolicy.BLOCKED_BUT_CAN_BE_PERSISTED, DEFAULT_BACKOFF_TIME_SECONDS);
171+
}
166172
} catch (Exception e) {
167173
InternalLogger.INSTANCE.error("Failed to send, unexpected exception: %s", e.getMessage());
168174
} catch (Throwable t) {

0 commit comments

Comments
 (0)