Ian Botsford
10/17/2024, 5:24 PMkeepAliveDuration
. From the TCP/SSL dumps I've examined, it appears the server is properly sending an SSL close_notify
message followed by a TCP FIN packet but it seems OkHttp doesn't recognize those when they happen. Much later, it may retrieve that connection from the pool, send a request, then attempt to read a response, upon which it throws an IOException: unexpected end of stream on <server-name>
.
So broad questions to start with: Is it expected that OkHttp ignores remote SSL/TCP closure events? And only discovers them after sending a request and attempting to read the response?yschimke
10/17/2024, 6:47 PMyschimke
10/17/2024, 6:48 PMIan Botsford
10/17/2024, 6:54 PMretryOnConnectionFailure(true)
the only way to handle this?yschimke
10/17/2024, 6:55 PMIan Botsford
10/17/2024, 6:56 PMyschimke
10/17/2024, 6:57 PMyschimke
10/17/2024, 6:58 PMIan Botsford
10/17/2024, 6:59 PMyschimke
10/17/2024, 7:21 PMyschimke
10/17/2024, 7:22 PMyschimke
10/17/2024, 7:26 PMIan Botsford
10/17/2024, 7:53 PMretryOnConnectionFailure(true)
would retry is only triggered after the request has been "sent". Now, because in this case the server has closed the connection, the data haven't really been _sent across the wire—_merely sent to some buffer somewhere, which presumably would timeout at some point.
But at that point in the call execution, it doesn't seem like OkHttp knows whether the data have actually made it to the wire. If the connection was broken after the request was sent and the call is not idempotent, it would not be safe to retry. Am I missing some other validation OkHttp uses to be safe about this? Or would setting retryOnConnectionFailure(true)
potentially expose us to re-executing non-idempotent calls?yschimke
10/17/2024, 8:02 PMyschimke
10/17/2024, 8:04 PMIan Botsford
10/17/2024, 8:09 PMyschimke
10/17/2024, 8:16 PMjessewilson
10/17/2024, 10:32 PMIan Botsford
10/18/2024, 11:24 PMRetryAndFollowUpInterceptor
...where is the special casing for GETs?jessewilson
10/19/2024, 12:20 AMjessewilson
10/19/2024, 12:21 AMIan Botsford
10/21/2024, 4:48 PMdoExtensiveHealthChecks
returns false for GET. Then RealConnection.isHealthy
uses that plus idle time to determine whether to invoke an additional socket-level test. So I can see how non-GET requests get extra verification of socket health on connection acquisition...is that the thing which prevents resending a non-idempotent request? Because I don't yet see how that affects the retry logic in RetryAndFollowUpInterceptor
. 🤔jessewilson
10/21/2024, 5:19 PM