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

Weird responses when sending more than one request to a Cowboy server #143

Closed
dabaer opened this Issue Jun 10, 2016 · 5 comments

Comments

Projects
None yet
4 participants
@dabaer

dabaer commented Jun 10, 2016

I'm getting some unexpected results when firing HTTPoison request()'s within 1 second of each other. Every second request I am consistently seeing some sort of cached response, where it falls and hits one of my cases, but it doesn't ping the URL at all.

case HTTPoison.request(:post, url, file) do
    {:ok, %HTTPoison.Response{status_code: 200, body: []}} ->
        # Work
    {:ok, %HTTPoison.Response{status_code: 400, body: body}} ->
        # This clause gets hit the first time correctly based on the response from the endpoint, and it also hits it the second time, but without firing a request at the endpoint at all...
    _ ->
        # More work
end

Regards,
Dakota

P.S. I wait until the request is fully complete on both sides before hitting it again.

@dabaer

This comment has been minimized.

Show comment
Hide comment
@dabaer

dabaer Jun 10, 2016

Upon further inspection it's started falling through to the catch all clause.

{:ok,
 %HTTPoison.Response{body: "",
  headers: [{"connection", "close"}, {"server", "Cowboy"},
   {"date", "Fri, 10 Jun 2016 15:36:59 GMT"}, {"content-length", "0"}],
  status_code: 505}}

Phoenix fains no indication that a request reached it, so I guess Cowboy is intervening before it reached phoenix, but i'm not sure why the HTTP version would not be valid.

dabaer commented Jun 10, 2016

Upon further inspection it's started falling through to the catch all clause.

{:ok,
 %HTTPoison.Response{body: "",
  headers: [{"connection", "close"}, {"server", "Cowboy"},
   {"date", "Fri, 10 Jun 2016 15:36:59 GMT"}, {"content-length", "0"}],
  status_code: 505}}

Phoenix fains no indication that a request reached it, so I guess Cowboy is intervening before it reached phoenix, but i'm not sure why the HTTP version would not be valid.

@dabaer dabaer changed the title from Response caching with request/5 to Weird requests when sending more than one request to a Cowboy server Jun 13, 2016

@dabaer dabaer changed the title from Weird requests when sending more than one request to a Cowboy server to Weird responses when sending more than one request to a Cowboy server Jun 13, 2016

@alakra

This comment has been minimized.

Show comment
Hide comment

alakra commented Jun 30, 2016

bump

@edgurgel

This comment has been minimized.

Show comment
Hide comment
@edgurgel

edgurgel Jun 30, 2016

Owner

I would double check if your cowboy code is not mixing "req" records. ninenines/cowboy#768

This may occur if you mix conn structs on Phoenix as well.

Owner

edgurgel commented Jun 30, 2016

I would double check if your cowboy code is not mixing "req" records. ninenines/cowboy#768

This may occur if you mix conn structs on Phoenix as well.

@edgurgel

This comment has been minimized.

Show comment
Hide comment
@edgurgel

edgurgel Jun 30, 2016

Owner

Just to exclude httpoison from this equation, set up an http server (using python, ruby, whatever) and send requests. You should get 505s.

Owner

edgurgel commented Jun 30, 2016

Just to exclude httpoison from this equation, set up an http server (using python, ruby, whatever) and send requests. You should get 505s.

@edgurgel edgurgel closed this Sep 1, 2016

@samrispaud

This comment has been minimized.

Show comment
Hide comment
@samrispaud

samrispaud Jan 4, 2017

this solved things for me and again cowboy doesn't like re-used requests and typheous does this by default. hope this helps someone in the future

this solved things for me and again cowboy doesn't like re-used requests and typheous does this by default. hope this helps someone in the future

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