Streaming command fails with a spurious timeout when reconnecting after an idle pause
Maintainers usually reply within 1 day
Assessment
This issue has not been assessed yet.
Description
Disclaimer: Although the following content is generated by AI, I have thoroughly reviewed and cleaned it.
Problem
A streaming command (e.g. a RemoteProcess whose output is read slowly) can fail with a spurious timeout:
TimeoutException: No response from the WinRM service
even though the server is healthy and reachable. It happens when the consumer pauses between two reads for longer than both the inactivity timeout and the host's idle keep-alive timeout (HTTP.sys drops idle connections after 120 s by default).
Cause
In streaming mode (HttpTransport.inactivityTimeout(int)), every request leg gets its own absolute deadline: post() arms deadlineEpochMillis = now + readTimeoutMillis before sending, and every socket wait (connect, TLS handshake, reads) is capped by what is left of it, with a 1 ms floor.
But when the server dropped the connection, WsmanClient.send() reconnects explicitly with transport.connect() before calling post() (so that connection failures can be retried safely, see #158). connect() does not arm a new deadline: it reuses the one left by the previous leg. If that leg started more than one inactivity timeout ago, the deadline has already expired, so:
Socket.connect(..., boundedByDeadline(connectTimeoutMillis))gets 1 ms- the TLS handshake (
setSoTimeout(boundedByDeadline(readTimeoutMillis))+startHandshake()) gets 1 ms
Over a real network, or with HTTPS, this fails with a SocketTimeoutException, which the streaming paths report as a TimeoutException.
A fresh operation is not affected (configureTimeouts() resets the deadline at the start of each operation). Only a reconnection within a streaming operation is.
Fix
In HttpTransport.connect(), when the per-leg deadline mode is active, arm a fresh deadline before connecting, so the explicit reconnection is a leg of its own. The pollTimeout mode (one absolute deadline shared by all legs) and the blocking mode (no deadline) are unchanged.
- Dominant language
- Java
- Stars
- 13
- Forks
- 4
- Avg merge
- 12h 44m
- Merged PRs (30d)
- 17
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MetricsHub/winrm-java
-
bug documentation
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
MetricsHub/winrm-java#202 ·
Maintainers usually reply within 1 day
-
WQL array properties: add the trailing separator to match wmi-javaPossibly taken @bertysentry claimed this 1 day ago. Openenhancement
Difficulty 3/5 1-2 days Newbie friendliness 58/100
MetricsHub/winrm-java#201 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 78/100
MetricsHub/winrm-java#199 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 30/100
MetricsHub/winrm-java#194 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 38/100
MetricsHub/winrm-java#176 ·
Maintainers usually reply within 1 day
All issues in MetricsHub/winrm-java
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
floci-io/floci#5425 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
objectionary/eo-graphs#80 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
objectionary/jucs#141 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
repowise-dev/repowise#3335 ·
Maintainers usually reply within 1 day