-
Notifications
You must be signed in to change notification settings - Fork 985
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
Handle all connection timeout messages in Patron #687
Handle all connection timeout messages in Patron #687
Conversation
I'm not sure if the test I wrote is a good one. I test the connection timeout against Googles 8.8.8.8 DNS server because it causes a connection timeout. If you don't like it we probably could remove the test from the Patron adapter test because the case, if a ::Patron::TimeoutError was raised correctly was not tested before anyway. This fixes #682 |
Hi @stayhero I had a look at the failing tests to see what's happening.
I don't have the time unfortunately to Google it and see why we're getting this, but apparently the situation is a little more complex than just 2 error messages. I would assume you need to manage at least another one |
@iMacTia Yep, I saw that. I'll look into it over the weekend. 😄 |
Hey @stayhero, did you have a chance to look into this 😃 ? |
@iMacTia Not yet. 🙈 Can you give me a week or two, I will try to solve this. :-) |
Of course 👍! Thanks for contributing. |
Hey @stayhero, sorry I'm just touching base to know if there's any progress on this. |
Yep. I'm going to work on it right now and tomorrow. What about the test? I guess simulating a timed out connection by trying to open 8.8.8.8 on port 88 probably isn't the best way. If you'd prefer a more stable approach (e. g. setting up an extra process listening on a port but timing out), this could take some more time. The other stuff should be easy. |
71a522e
to
4f5f978
Compare
@iMacTia Tests are passing now. I added the string that caused Travis to fail and a couple of other strings I found in the cURL github repo. I'm not sure if it's ok to raise a ::ConnectionFailed exception in cases where DNS resolving does time out but I guess it's better than raising a ::TimeoutError. I guess you could merge this pull request but I will try to improve the test as described above. |
Great work so far 👍! If in the meantime you can also get the tests improved as you suggested above, that would be even better 😃 ! |
@stayhero error messages look all good to me!
You're totally right on the above, and I already have a ticket for that (#718). Regarding the tests improvement, we already have a LiveServer in our test suite (https://github.com/lostisland/faraday/blob/master/test/live_server.rb) so you may want to use that one to save some time 😃 |
Hi @stayhero I'll probably release Faraday 0.14.0 this week so please let me know if you're close to improve the tests and I'll wait to merge this is 👍 |
@iMacTia Not even started working on it, unfortunately. I'm not sure about this week, as I'm rather busy lately. 🙈 |
lib/faraday/adapter/patron.rb
Outdated
"name lookup timed out", | ||
"timed out before SSL", | ||
"connect() timed out" | ||
].any? { |curl_message| message.include?(curl_message) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define this array in a constant and .freeze
it to improve performances
No worries @stayhero, I'm happy to merge this in even without the additional test, those can be added separately. |
Patron is able to differentiate between a connection timeout and a normal (send or receive) timeout. The Faraday Patron adapter throws an ::Patron::TimeoutError in case of a connection timeout. Unfortunately the Patron adapter needs to parse the original error message thrown by the curl library. Up until now the Patron adapter expected the error message to be "Connection time-out". curl on the other hand throws another error message when a connection timeout happens: see https://github.com/curl/curl/blob/e60fe20fdf94e829ba5fce33f7a9d6c281149f7d/lib/multi.c#L1375 Connection timed out after %ld milliseconds Therefore to properly catch all cases of a connection timeout we need to support both error messages.
8f5203b
to
3b78261
Compare
🤔 I currently have no idea why the Travis checks are failing now. Starting the test locally the results are like this:
Looks like an "issue" within net_http? 🤔 |
@stayhero I noticed that in master as well, I think that's a separate issue and you haven't introduced the bug. We're performing a call to Google and that was working but apparently now it doesn't work anymore... I'll fix that separately, thanks for adding the |
@stayhero the travis issue is now fixed in master 🎉🎉🎉 |
@iMacTia 👏 Done, but one test failing with Ruby 2.4.0 with SSL. 😢 |
I can't believe that.... let me have a look 😭 |
A re-run made it pass 👍 |
Patron is able to differentiate between a connection timeout and a normal (send or receive) timeout. The Faraday Patron adapter throws a ::Patron::TimeoutError in case of a connection timeout.
Unfortunately the Patron adapter needs to parse the original error message thrown by the curl library. Up until now the Patron adapter expected the error message to be "Connection time-out".
curl on the other hand throws another error message when a connection timeout happens:
https://github.com/curl/curl/blob/e60fe20fdf94e829ba5fce33f7a9d6c281149f7d/lib/multi.c#L1375
Therefore to properly catch all cases of a connection timeout we need to support both error messages.