Skip to content
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
Closed

Comments

@dabaer
Copy link

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
Copy link
Author

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 Response caching with request/5 Weird requests when sending more than one request to a Cowboy server Jun 13, 2016
@dabaer dabaer changed the title Weird requests when sending more than one request to a Cowboy server Weird responses when sending more than one request to a Cowboy server Jun 13, 2016
@alakra
Copy link

alakra commented Jun 30, 2016

bump

@edgurgel
Copy link
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.

@edgurgel
Copy link
Owner

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 as completed Sep 1, 2016
@samrispaud
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants