jira-importer opened a new issue, #1130: URL: https://github.com/apache/httpcomponents-core/issues/1130
**[David Koski](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=dkoski)** opened **[HTTPCORE-149](https://issues.apache.org/jira/browse/HTTPCORE-149?redirect=false)** and commented This code in BaseIOReactor protected void timeoutCheck(final SelectionKey key, long now) { Object attachment = key.attachment(); if (attachment instanceof SessionHandle) { SessionHandle handle = (SessionHandle) key.attachment(); IOSession session = handle.getSession(); int timeout = session.getSocketTimeout(); if (timeout > 0) { if (handle.getLastReadTime() + timeout < now) { is looking at the last read time. This will be the creation of the connection (if new) or the last time the session was used, if a keepalive connection. If what you connect to has relatively high idle times on its keepalive connections (say 60s) and you submit a request against it after it has been idle for 15 seconds, you lose 15 seconds off your actual timeout. For example, in my submitRequest: public HttpRequest submitRequest(final HttpContext context) { i set the read timeout on a per request basis: if (timeout != null) { connection.setSocketTimeout((int) timeout.getReadTimeout()); } to, e.g. 120 s. My request is for this cgi: #!/bin/sh echo "content-type: text/plain" echo "" sleep 110 ls If I use an existing session, this typically times out because it counts from the last read from the request. Further evidence, if I have the session and I reset the last read time in submitRequest(), it works correctly: try { final Field field = session.getClass().getDeclaredField("key"); field.setAccessible(true); final SelectionKey key = (SelectionKey) field.get(session); final SessionHandle handle = (SessionHandle) key.attachment(); handle.resetLastRead(); } catch (final Exception e) { log.debug("unable to access key", e); } --- **Affects:** 4.0-alpha6 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
