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

no case clause matching: {:error, :badarg} #191

Closed
AntonFagerberg opened this Issue Jun 2, 2015 · 12 comments

Comments

Projects
None yet
5 participants
@AntonFagerberg

AntonFagerberg commented Jun 2, 2015

I'm load testing a system I've built in Elixir which is using Hackney to send requests. The problem is that sometimes (yes, unfortunately sometimes) when I crank up the number of requests executed concurrently I get a matching error which seems to happen because of a missing case clause inside Hackney:

** (exit) an exception was raised:
    ** (CaseClauseError) no case clause matching: {:error, :badarg}
        (hackney) src/hackney_client/hackney_response.erl:74: :hackney_response.wait_status/1
        (hackney) src/hackney_client/hackney.erl:357: :hackney.send_request/2

I'm afraid I don't have any code in which I can replicate this issue, but please tell me if there is any additional information I can provide.

Here's the Hackney code which seems to fail: https://github.com/benoitc/hackney/blob/master/src/hackney_client/hackney_response.erl#L74

@benoitc benoitc added this to the 1.1.1 milestone Jun 6, 2015

@benoitc benoitc added the bug label Jun 6, 2015

@zweizeichen

This comment has been minimized.

zweizeichen commented Jun 15, 2015

Yup - same problem here when increasing the number of requests/s. @AntonFagerberg Are you sure this is a problem of Hackney and not the server we're querying?

@benoitc

This comment has been minimized.

Owner

benoitc commented Jun 15, 2015

is there any url I could test on? Or does it happen on any server?

@zweizeichen

This comment has been minimized.

zweizeichen commented Jun 15, 2015

Just set up a simple test and ran 10k parallel requests with HTTPoison and a local Cauldron server. Everything ran just fine. I then introduced random response delays on the server up to 10 seconds and it still worked flawlessly for 1k requests, I'm getting the error more than once per second when I'm running at around 150 requests per second for a while in a real-world scenario (public API server, nginx 1.2 I think). Maybe it's related to some connections hanging or something like that. It only happens when I query the 'real' server.

@benoitc benoitc modified the milestones: 1.1.1, 2.0.0 Jun 16, 2015

@AntonFagerberg

This comment has been minimized.

AntonFagerberg commented Jun 17, 2015

@zweizeichen No, not sure if it's Hackney or a bad behaving web server. I have tried to recreate this bug in every way I can think of today but I've been unable to do so...

@benoitc benoitc removed this from the 1.1.1 milestone Jun 25, 2015

@benoitc

This comment has been minimized.

Owner

benoitc commented Jun 25, 2015

me either. And I tried hard.... can you try the latest master?

@unitymind

This comment has been minimized.

unitymind commented Jun 28, 2015

Similar issue, but different pattern matching case:

(CaseClauseError) no case clause matching: {:error, :bad_request}
            (hackney) src/hackney_client/hackney_response.erl:74: :hackney_response.wait_status/1
            (hackney) src/hackney_client/hackney.erl:357: :hackney.send_request/2

Reproducing: trying to get request using http schema in url (e.g. http://127.0.0.1:2376) where is 2375 port is TLS/SSL. If change url to https schema (e.g. https://127.0.0.1:2376) - works as expected.

Sometimes no information about http or https schema on the end-port. The best solution: transparency switch from http to https. But just handle this case in pattern matching would be great too :)

@benoitc

This comment has been minimized.

Owner

benoitc commented Jun 29, 2015

@unitymind thanks for the tests. The error should happen during handshake then, I will have a look on ho to catch the error in the coming release.

@benoitc benoitc added this to the 2.0.0 milestone Jun 29, 2015

@unitymind

This comment has been minimized.

unitymind commented Jun 29, 2015

Currently I am use workaround:

try do
...
rescue
  e in CaseClauseError ->
    case e do
      %CaseClauseError{ term: { :error, :bad_request } } ->
        check_base_url(url |> String.replace("http://", "https://"))
    end
end

recursive call with schema changing.

@benoitc

This comment has been minimized.

Owner

benoitc commented Jun 29, 2015

Thanks :) The error is happening on connect, with the new connection api it
will be easier to fix it. New release is planned this week. it will be
partly based on the hackney_socks release.
On Mon 29 Jun 2015 at 06:26 Vitaliy V. Shopov notifications@github.com
wrote:

Currently I am use workaround:

try do
...
rescue
e in CaseClauseError ->
case e do
%CaseClauseError{ term: { :error, :bad_request } } ->
check_base_url(url |> String.replace("http://", "https://"))
end
end

recursive call with schema changing.

Think so the most non-destructive solution is return { :error, %HTTPoison.Error {} }


Reply to this email directly or view it on GitHub
#191 (comment).

@unitymind

This comment has been minimized.

unitymind commented Jun 29, 2015

Thanks for your efforts! )

@benoitc benoitc modified the milestones: 2.0.0, 1.3.2 Aug 21, 2015

@benoitc benoitc removed this from the 2.0.0 milestone Aug 21, 2015

@cwc

This comment has been minimized.

cwc commented Jan 4, 2016

Any update on this?

@benoitc

This comment has been minimized.

Owner

benoitc commented Jan 8, 2016

@cwc a nrew release of hackney will land on next monday.

@benoitc benoitc removed this from the 1.3.2 milestone Jan 25, 2016

@benoitc benoitc closed this Apr 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment