From 9a943236c12a0a1b670564f164ba60e8f9ce3f4e Mon Sep 17 00:00:00 2001 From: nkramer44 Date: Sat, 1 Feb 2020 00:26:24 -0500 Subject: [PATCH] Log warning when HTTP client timeout is too low (#428) * added warning log when http timeout is less than ilp expiry Signed-off-by: nkramer44 --- .../java/org/interledger/link/http/IlpOverHttpLink.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/link-parent/link-ilp-over-http/src/main/java/org/interledger/link/http/IlpOverHttpLink.java b/link-parent/link-ilp-over-http/src/main/java/org/interledger/link/http/IlpOverHttpLink.java index 4b7b1e06..25d9f774 100644 --- a/link-parent/link-ilp-over-http/src/main/java/org/interledger/link/http/IlpOverHttpLink.java +++ b/link-parent/link-ilp-over-http/src/main/java/org/interledger/link/http/IlpOverHttpLink.java @@ -41,6 +41,8 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.time.Duration; +import java.time.Instant; import java.util.Objects; import java.util.Optional; import java.util.function.Supplier; @@ -120,6 +122,12 @@ public IlpOverHttpLink( public InterledgerResponsePacket sendPacket(final InterledgerPreparePacket preparePacket) { Objects.requireNonNull(preparePacket); + if (preparePacket.getExpiresAt() != null && + okHttpClient.readTimeoutMillis() <= Duration.between(Instant.now(), preparePacket.getExpiresAt()).toMillis()) { + logger.warn("OkHttpClient read timeout is shorter than the Prepare Packet's timeout. " + + "This may result in an HTTP timeout while unexpired ILP packets are in flight."); + } + final Request okHttpRequest; try { final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();