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

{ssl_close, Socket} message is sent to wrong process when server responds with "keep-alive" header #130

Closed
chvanikoff opened this issue Oct 7, 2014 · 2 comments

Comments

@chvanikoff
Copy link

The issue can be reproduced on https://www.cloudflare.com for example:
when I call hackney:request/5 and hackney:body/1, after keep-alive timeout when the connection is closed, the close message is sent to calling PID (which called request/5). I guess it should be handled by hackney in some way.

@benoitc
Copy link
Owner

benoitc commented Oct 11, 2014

Can you give me a full example of the full request? (any confidential thing removed of course).

@chvanikoff
Copy link
Author

Nothing specific, this is complete example of how to reproduce the issue:

-module(hackneytest).
-behaviour(gen_server).
-export([start_link/0, init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).

start_link() -> gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).

init([]) ->
  {_, {H, M, S}} = calendar:now_to_universal_time(now()),
  io:format("[~p:~p:~p] Request sent~n", [H, M, S]),
  {_, _, _, Client} = hackney:request(get, <<"https://www.cloudflare.com">>, [], <<>>, []),
  _Reply = hackney:body(Client),
  {ok, []}.

handle_call(_, _, State) -> {reply, noreply, State}.

handle_cast(_, State) -> {noreply, State}.

handle_info(Request, State) ->
  {_, {H, M, S}} = calendar:now_to_universal_time(now()),
  io:format("[~p:~p:~p] This is unexpected here: ~p~n", [H, M, S, Request]),
  {noreply, State}.

terminate(_Reason, _State) -> ok.

code_change(_OldVsn, State, _Extra) ->  {ok, State}.

Once the server is started it takes about a minute for me to receive unexpected msg (I guess it's not constant time and related to some env variable)

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

2 participants