[99s-extend] Problems with Bullet

Lee Sylvester lee.sylvester at gmail.com
Mon Apr 8 15:53:38 CEST 2013


Hi all,

I'm currently having problems getting a websocket to connect to a simple bare bones Bullet handler.  Unfortunately, I'm still quite an Erlang noob, so the stack traces tend to lead me in circles.  I'm hoping this is obvious stuff to you Erlang pros :-)

Given the below handler:

init(_Transport, Req, _Opts, _Active) ->
	{ok, Req, undefined_state}.

stream(Data, Req, State) ->
	{ok, Req, State}.

info(Info, Req, State) ->
	{reply, Info, Req, State}.
	
terminate(_Req, _State) ->
	ok.

Connecting with a websocket throws the following error:

=ERROR REPORT==== 8-Apr-2013::14:46:11 ===
** Cowboy handler bullet_handler terminating in init/3
   for the reason error:undef
** Options were [{handler,connection_handler}]
** Request was [{socket,#Port<0.926>},
                {transport,ranch_tcp},
                {connection,keepalive},
                {pid,<0.491.0>},
                {method,<<"GET">>},
                {version,{1,1}},
                {peer,{{127,0,0,1},56630}},
                {host,<<"localhost">>},
                {host_info,undefined},
                {port,8080},
                {path,<<"/">>},
                {path_info,undefined},
                {qs,<<"encoding=text">>},
                {qs_vals,undefined},
                {fragment,<<>>},
                {bindings,[]},
                {headers,[{<<"upgrade">>,<<"websocket">>},
                          {<<"connection">>,<<"Upgrade">>},
                          {<<"host">>,<<"localhost:8080">>},
                          {<<"origin">>,<<"http://www.websocket.org">>},
                          {<<"pragma">>,<<"no-cache">>},
                          {<<"cache-control">>,<<"no-cache">>},
                          {<<"sec-websocket-key">>,
                           <<"fEj/SOOcQgSKATOjhbNJBQ==">>},
                          {<<"sec-websocket-version">>,<<"13">>},
                          {<<"sec-websocket-extensions">>,
                           <<"x-webkit-deflate-frame">>}]},
                {p_headers,[{<<"connection">>,[<<"upgrade">>]}]},
                {cookies,undefined},
                {meta,[]},
                {body_state,waiting},
                {multipart,undefined},
                {buffer,<<>>},
                {resp_compress,false},
                {resp_state,waiting},
                {resp_headers,[]},
                {resp_body,<<>>},
                {onresponse,undefined}]
** Stacktrace: [{bullet_handler,init,
                    [{tcp,http},
                     {http_req,#Port<0.926>,ranch_tcp,keepalive,<0.491.0>,
                         <<"GET">>,
                         {1,1},
                         {{127,0,0,1},56630},
                         <<"localhost">>,undefined,8080,<<"/">>,
                         undefined,<<"encoding=text">>,undefined,<<>>,
                         [],
                         [{<<"upgrade">>,<<"websocket">>},
                          {<<"connection">>,<<"Upgrade">>},
                          {<<"host">>,<<"localhost:8080">>},
                          {<<"origin">>,<<"http://www.websocket.org">>},
                          {<<"pragma">>,<<"no-cache">>},
                          {<<"cache-control">>,<<"no-cache">>},
                          {<<"sec-websocket-key">>,
                           <<"fEj/SOOcQgSKATOjhbNJBQ==">>},
                          {<<"sec-websocket-version">>,<<"13">>},
                          {<<"sec-websocket-extensions">>,
                           <<"x-webkit-deflate-frame">>}],
                         [{<<"connection">>,[<<"upgrade">>]}],
                         undefined,[],waiting,undefined,<<>>,false,waiting,[],
                         <<>>,undefined},
                     [{handler,connection_handler}]],
                    []},
                {cowboy_handler,handler_init,4,
                    [{file,"src/cowboy_handler.erl"},{line,69}]},
                {cowboy_protocol,execute,4,
                    [{file,"src/cowboy_protocol.erl"},{line,514}]}]

Can anyone see what might be throwing this off?  I'd like to get a minimal handler running before I attempt to add some logic.

Thanks,
Lee


More information about the Extend mailing list