-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
HTTP::Client hangs #4650
Comments
can you give full example to reproduce? this is not compiled |
Sorry, I fix it. Try now |
Hi. There is one suggestion, I think the problem appear when I upgrade Crystal from 0.21 to 0.22. And in 0.22 have been added OpenSSL 1.1.0 support. I'm not sure, but maybe it's here. Because before I saw match more errors with SSL in my app. |
if your try site without https, it hangs? |
I've tried to make it with http and there was no issues for 50 loops. With https it happens every 5 loops or less @ysbaddaden Can you please take a part of discussion as an author of support for OpenSSL 1.1.0 (See #4215, #4230, thanks @ysbaddaden)? |
http probably just serves a redirect to https so it may not be a good indicator |
@oprypin I've tested it on site without redirects, so I think the problem is somewhere between http client and openssl |
Which OpenSSL version is being linked and used? |
Using your sample, I can't reproduce on Ubuntu 14.04 (trusty) with Crystal 0.23 (compiled from source) and OpenSSL 1.0.1f (official package), even after running numerous times.
|
require "openssl"
tcp_socket = TCPSocket.new("www.google.com", 443)
ssl_socket = OpenSSL::SSL::Socket::Client.new(tcp_socket) |
OpenSSL 1.0.2g 1 Mar 2016 |
Since newer versions 1.0.2h and 1.1.0e both fail, there is probably no point in upgrading. @ysbaddaden The reduced sample does not raise an SSL error with 1.0.2g and Crystal 0.23.0 |
My issue was unrelated: I compiled from source and openssl couldn't find the system certs... with proper links it now works correctly. Sorry for the noise. I can't reproduce your issue with OpenSSL versions 1.0.1f, 1.0.2h or 1.1.0e. |
@ysbaddaden Can you send me your compiled file. I'll run it on my PC? [email protected] |
I guess you'd just hit issues with shared libs. |
@ysbaddaden can you advise me what to do? how to find and fix... I'm trying to catch it for 3 days already( |
I don't think this is going to work because the ubuntu repo only contains the latest version IIRC. You'll have to install prior releases manually from https://github.com/crystal-lang/crystal/releases |
I've just installed Ubuntu 14.04 and run my example code on it. The result is absolutely same, my app hangs. Ok, it was 97% CPU, not 100% but this is the only difference. I can't understand why this issue is reproducible by me only( |
Yeah, I've tried you're code sample with the same setup Ubuntu 16.04, Crystal 0.23.0, LLVM 3.8.1, OpenSSL 1.0.2.g and it works :/ Could you add some |
@straight-shoota My "puts" debugging brings me here:
It starts but never ends. And with little improvement of code And it's not about concurrency.. I've tried it with only main fiber and result is same. I can't understand what's wrong.. Did you try code with Instagram? I work with different social media and it happens only with Insta. |
Hi everyone! Maybe I should write i somewhere else, if so tell me please.
|
If you continue with lldb and get trace again is it always in the same place? is reader.cr yours? Also you may be able to see what bytes its hanging on by using tcpdump or what not (is the port still open? etc.) |
@rdp Yes, the place is always same. And reader.cr is Crystal source file. |
If you open it in lldb does it let you "step" after pausing it?
…On Thu, Jul 6, 2017 at 11:47 AM, nobilik ***@***.***> wrote:
@rdp <https://github.com/rdp> Yes, the place is always same. And reader.cr
is Crystal source file.
Anyway, I can't understand what it is. But I install new Ubuntu 16.04 on
VirtualBox and here my test code works without hanging. I try to run
compiled file on host machine (my computer) but have got same issue. I
compiled it again on VM but with '-static' this time. Guess what? Nothing
change, it still hangs on host machine. Should I close the issue in this
case?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4650 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAw0J6NAkh8-PPuyK-BkjlVnn7WJnn5ks5sLR28gaJpZM4OLSHR>
.
|
@rdp Yes, "step" is possible. Actually I start with lldb from putting breakpoint in io.cr gets_to_end method. |
It's clearly a problem in |
Where does step "go" is it stepping through crystal code? If so where does
it go? You may find it is doing some tight inner loop over and over...
…On Thu, Jul 6, 2017 at 7:42 PM, nobilik ***@***.***> wrote:
@rdp <https://github.com/rdp> Yes, "step" is possible. Actually I start
with lldb from putting breakpoint in io.cr gets_to_end method.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4650 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAw0Mu8bOejbAHasI_xWUMYhggi1Marks5sLYzvgaJpZM4OLSHR>
.
|
@rdp can't catch the issue with breakpoint. Execution is too slow I think |
Well see if you can find some "busy loop" (set breakpoints on each line of
crystal code mentioned in the stacktrace, then "run" and "continue"). See
if you can find some "busy loop" GL!
…On Sat, Jul 8, 2017 at 3:58 AM, nobilik ***@***.***> wrote:
@rdp <https://github.com/rdp> can't catch the issue with breakpoint.
Execution is too slow I think
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4650 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAw0AMI6YZcanteCn_4NcWfsvlmTptPks5sL1KpgaJpZM4OLSHR>
.
|
Hi, I succeed to 'step in' with lldb after hanging, but I have no enough experience to understand. So I can step till this:
after that stepping gives me only empty space and while stepping I have 100% CPU load. If I do ctrl + C and step again CPU becomes 100% loaded again and output is same. There is more output in attachment. Thanks for help. |
OK there are definitely some questions in that output, like this block:
But I guess that's just exiting the signal handler so expected, since SIGPIPE is being generated but handled in other ways. I was able to repro the behavior using the given snippet on on If I add this puts line to flate/reader.cr
I eventually get this output repeated "forever" to the console (i.e. it seems to be hanging looping with this):
If I add BUF_ERROR to the throw block:
it works "better" (well it doesn't busy loop anymore for me --no idea if this is the "best" way to handle it, are there other conditions that should go here as well?). It does seem to mess with your channel receive logic though. You might need something like:
Wonder what the "approved" way of closing like this is, or if there is some better way here as well? Maybe #close should swallow failures? Not sure, but definitely with the above suggested BUF_ERROR change the #close method can also throw Broken pipe exceptions FWIW. |
Cool! I can confirm that adding
This block was only for snippet code. Ordinary I use pool of HTTP.clients. |
Can we close this? |
No, nothing was fixed, it's still a bug |
So it seems probable to me that what's happening is that the slice passed to If someone could provide me with a file where this happens, we can make a spec for it and debug it. I think we might have to introduce being able to write into a larger buffer than the one given to read though. |
I haven't looked closely but wonder if it is being passed only 0 bytes even? Hmm...or even "1 byte" (which can't be deflated) but that's the "last byte" (b/c of truncated input) so it's looping forever...hmm... |
@Sija Hi! My test app works well now. Sorry I can't try it on production for now, but I think it's fixed. Thanks! |
Let's close this. If it turns out #6610 didn't fix this, please re-open. |
I don't have big experience as issue writer, but I'll try
When I use HTTP::Client with concurrency >= 5 (for sure, maybe less) my app completely hangs with no output. From time to time it can pass but it happens seldom.
TOP
shows:There is no any output with
strace
also.Crystal 0.23.0 [3c3d3e2] (2017-06-28) LLVM 3.8.1
Ubuntu 16.04.2 LTS
The text was updated successfully, but these errors were encountered: