-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
org.eclipse.jetty.client.HttpRequest.send() never returns #8584
Comments
A few more points:
Here is my
I doubt I'll be able to reproduce this with Jetty verbose logging enabled because the issue might be timing-related. |
Is this HttpClient only using HTTP/1 or is it setup for HTTP/2 as well? |
@joakime I'm fairly sure I'm only using HTTP/1, but how can I check to be sure? PS: I tried reproducing the issue with |
Another thing that comes to mind is that I'm using Intellij's Hotswap feature to modify the application's code without restarting the JVM. Is it possible that hotswap is somehow screwing up Jetty's state? I'll let you know if I run across this bug without using hotswap. |
This looks like a real bug. I've reproduced it without the use of hot swap, even running completely from command-line without any sort of debugging taking place. How do we go about debugging this further? |
In the minutes preceding this hang, I see request response time increases from a few seconds to multiple minutes. I'm not sure if this is thread starvation or some sort of network throttling introduced by the servers I am hitting. Is it theoretically possible for a server to keep a connection alive forever yet send no actual data over the wire (as a form of network throttling)? If so, are there any sort of timeouts I can set on the client side that would force the connection to timeout? UPDATE: |
I think I found a solution. I registered event listeners with I'll let you know in a couple of days. |
Unfortunately, the hang still occurs. I would appreciate your advice on how to best track this back to the source. It's difficult to figure out because the issue is intermittent. Are there any sort of event listeners I should make use of? Any sort of logging I should enable? Remember, if I enable too many logs the problem seems to go away... so it's probably some sort of race condition. |
Any idea what would cause an HTTP request to stay in the queued state forever? I've got Also, does invoking Thank you. |
@cowwoc I'll look into this. Are your logs 16 GiB compressed? |
@cowwoc the DEBUG logs will be great if you can provide them. My impression is that this has something to do with the SOCKS configuration. The DNS resolution should be subject to After the address is resolved, the connect attempt is subject to the After the connection is created, we have an It could be that we don't handle well the case where the SOCKS proxy just does not reply ever to the client. What class is |
@sbordet Sorry for the delayed response. The original logs I collected did not contain enough information to track the transition from application threads to Jetty's threads and back. As usually happens in such cases, adding logs made the problem harder to reproduce. I'll let you know as soon as I've got updated logs showing this problem. What's weird is that I've added a scheduled task that invokes Would synchronous SOCKS address resolution abort correctly when
|
@sbordet Got it!
I am attaching the thread dump for your review. The log output is 47GB uncompressed. Are you able to extract RAR or 7ZIP formats if I use them instead of classic zip? The RAR compressed size should be around 2GB. |
It looks like this is the default so I should be good: https://github.com/eclipse/jetty.project/blob/e3b0e80857cd3f2218f925702b22466a0c4e8bf7/jetty-client/src/main/java/org/eclipse/jetty/client/HttpClient.java#L211
That, or the server itself could be hanging the response forever as a form of throttling. Were you successful in reproducing this in a testcase? |
Looking at https://github.com/apache/mina-sshd/blob/65b80b57c9a9b474e8b42a6db6908425e92680a6/sshd-core/src/main/java/org/apache/sshd/core/CoreModuleProperties.java#L280 and https://github.com/apache/mina-sshd/blob/65b80b57c9a9b474e8b42a6db6908425e92680a6/sshd-core/src/main/java/org/apache/sshd/core/CoreModuleProperties.java#L338 it looks like the default sshd read timeouts are infinity. If the server does not send a reply then sshd will never time out and it is left to Jetty to enforce some sort of timeout. I assume you already handle this case if there is no proxy...? If so, I would expect the same timeout configuration option to get used for when a proxy exists. |
I might have missed it, but how is SSH involved here? You open an SSH tunnel and you send SOCKS through that SSH tunnel? Also, can you clarify, when you send the request, if you set a total timeout, an idle timeout and whether you use the blocking |
Fixed handling of the idle timeout in case the SOCKS proxy does not reply to the SOCKS bytes. Signed-off-by: Simone Bordet <[email protected]>
@cowwoc can you build and try the changes in branch |
Correct.
I couldn't find a mechanism to enforce total timeout in Jetty (let me know if I missed it) so I implemented my own. I schedule I did not set an idle timeout before running into this bug. After I did, I decided to set a total-request timeout instead because a malicious server could game Yes, I am using the blocking I'll let you know if |
FTR, |
@sbordet I'm 1:15 hours into the test and so far so good. Maybe it's a coincidence, but the transfer rates I'm getting now are way better than before... If more and more connections were converted into zombies in the past, it's conceivable that this would reduce the overall transfer speed. Assuming that this fix works, is there a workaround I can use in production until you publish an official release? Or am I dependent on this private build? |
|
@sbordet I think your fix works. I left the application running for 5 hours and it didn't hang once. Going back to my earlier question: is there a workaround that I can use in production until the fix makes it into an official release? I assume the next release is 3 months away which is an eternity for me :) |
@cowwoc I think that if you set a total timeout to your requests you can workaround the immediate problem of requests never returning. |
@cowwoc do you confirm that the changes fix this issue? |
@sbordet Yes. It looks fixed to me. Thank you. |
Fixed handling of the idle timeout in case the SOCKS proxy does not reply to the SOCKS bytes. Signed-off-by: Simone Bordet <[email protected]>
@sbordet Apologies, but I think this bug is not fixed. Should I open a new bug report or do you prefer re-opening this ticket? To clarify, I checked out the v11 branch (commit 77ceb41), built a local SNAPSHOT version and used that to run my application. I ended up with a hang which again seems centered around For example, take a look at Thread Also, you should note that I discovered a JDK bug a few days back that might be relevant: https://youtrack.jetbrains.com/issue/IDEA-305072 The above hang occurred while running my application under IDEA in debug mode. I have never seen this bug affect virtual threads before, but anything is possible... Let me know if you need me to collect any other logs, and what you think of the thread dump. |
@cowwoc, first of all virtual threads are experimental, preview, etc. -- could be an OpenJDK bug. Does it happen when you run without virtual threads? Do you have DEBUG logs for this failure? |
@sbordet I think you're right. Upon digging further into the issue I noticed that the problem went away if I switched from thread-per-request to a fixed-size thread pool. Eventually this led me to the discovery of a memory leak in the JDK as well as in IDE I was using. Here are the relevant links in case anyone else is interested: https://youtrack.jetbrains.com/issue/IDEA-305072 The JDK issues have been fixed. Once IDEA fixes their memory leak I will retest and hopefully the hang will disappear. |
Jetty version(s): 11.0.11
Java version/vendor
(use: java -version)
OS type/version Microsoft Windows [Version 10.0.19044.2006]
Description
Do not report security issues here! See Jetty Security Reports.
How to reproduce?
I'm seeing an intermittent situation where invoking
org.eclipse.jetty.client.HttpRequest.send()
blocks forever even though I'm using the default idle timeout of 30 seconds.Here is the stack dump: stacktrace.txt
Here is a summary from Intellij:
248 waiting threads::
8 runnable threads:
1 waiting thread:
34 waiting threads:
main thread waiting on:
1 runnable thread:
2 waiting threads:
1 waiting thread:
996 waiting threads:
1 waiting thread:
1 runnable thread:
1 sleeping thread:
1 runnable thread:
1 waiting thread:
3 runnable threads:
As far as I can tell, my worker threads are waiting on
org.eclipse.jetty.client.HttpRequest.send()
to return and it's not clear what Jetty is waiting on. Any ideas?The text was updated successfully, but these errors were encountered: