nitrogen / simple_bridge

A simple, standardized interface library to Erlang HTTP Servers.
MIT License
112 stars 76 forks source link

Cowboy websocket error when changing page #37

Closed fooflare closed 9 years ago

fooflare commented 9 years ago

I got this error, after creating a cowboy app, just clicking in the mobile sample link:

=ERROR REPORT==== 30-Sep-2014::01:01:07 === Ranch listener http had connection process started with cowboy_protocol:start_link/4 at <0.214.0> exit with reason: {[{reason,undef},{mfa,{cowboy_simple_bridge_anchor,websocket_terminate,3}},{stacktrace,[{cowboy_simple_bridge_anchor,websocket_terminate,[{remote,1001,<<>>},{http_req,#Port<0.3893>,ranch_tcp,keepalive,<0.214.0>,<<"GET">>,'HTTP/1.1',{{127,0,0,1},36985},<<"localhost">>,undefined,8000,<<"/about">>,undefined,<<>>,undefined,[],[{<<"host">>,<<"localhost:8000">>},{<<"user-agent">>,<<"Mozilla/5.0 (X11; Linux x8664; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.1.0">>},{<<"accept">>,<<"text/html,application/xhtml+xml,application/xml;q=0.9,/_;q=0.8">>},{<<"accept-language">>,<<"es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3">>},{<<"accept-encoding">>,<<"gzip, deflate">>},{<<"dnt">>,<<"1">>},{<<"sec-websocket-version">>,<<"13">>},{<<"origin">>,<<"http://localhost:8000">>},{<<"sec-websocket-key">>,<<"d+YikKQp6fvO+Q4mZl7Z8Q==">>},{<<"cookie">>,<<"utma=111872281.300584001.1406903199.1412004910.1412029354.10; utmz=111872281.1406903199.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); csrftoken=nI68lLnJ0Ctvf1hn3Fi3T6Qp2lf7OrfR; newcookie=A-vR5QgY9hu9BRrOWSMJPG5SCiTNOA94DyL5IVXvZZjouXPgP1S8MHeYpV2zik3PG9tK7eNGSKzh7BtFcB9JwVy5WtfQKxDMdvRxVfFL84ftgL6nuOFr_yHjw-GUwsWqSJLYPg; utmb=111872281.6.10.1412029354; utmc=111872281">>},{<<"connection">>,<<"keep-alive, Upgrade">>},{<<"pragma">>,<<"no-cache">>},{<<"cache-control">>,<<"no-cache">>},{<<"upgrade">>,<<"websocket">>}],[{<<"upgrade">>,[<<"websocket">>]},{<<"connection">>,[<<"keep-alive">>,<<"upgrade">>]}],undefined,[{websocket_compress,false},{websocket_version,13}],waiting,undefined,<<>>,false,done,[],<<>>,undefined},{ws_state,nitrogen,{sbw,cowboy_simple_bridge,{cowboy_bridge,#Ref<0.0.0.311>},false,[],[],[],none,[{<<"host">>,<<"localhost:8000">>},{<<"user-agent">>,<<"Mozilla/5.0 (X11; Linux x8664; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.1.0">>},{<<"accept">>,<<"text/html,application/xhtml+xml,application/xml;q=0.9,/_;q=0.8">>},{<<"accept-language">>,<<"es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3">>},{<<"accept-encoding">>,<<"gzip, deflate">>},{<<"dnt">>,<<"1">>},{<<"sec-websocket-version">>,<<"13">>},{<<"origin">>,<<"http://localhost:8000">>},{<<"sec-websocket-key">>,<<"d+YikKQp6fvO+Q4mZl7Z8Q==">>},{<<"cookie">>,<<"utma=111872281.300584001.1406903199.1412004910.1412029354.10; utmz=111872281.1406903199.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); csrftoken=nI68lLnJ0Ctvf1hn3Fi3T6Qp2lf7OrfR; newcookie=A-vR5QgY9hu9BRrOWSMJPG5SCiTNOA94DyL5IVXvZZjouXPgP1S8MHeYpV2zik3PG9tK7eNGSKzh7BtFcB9JwVy5WtfQKxDMdvRxVfFL84ftgL6nuOFr_yHjw-GUwsWqSJLYPg; utmb=111872281.6.10.1412029354; utmc=111872281">>},{<<"connection">>,<<"keep-alive, Upgrade">>},{<<"pragma">>,<<"no-cache">>},{<<"cache-control">>,<<"no-cache">>},{<<"upgrade">>,<<"websocket">>}],[{<<"utma">>,<<"111872281.300584001.1406903199.1412004910.1412029354.10">>},{<<"utmz">>,<<"111872281.1406903199.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)">>},{<<"csrftoken">>,<<"nI68lLnJ0Ctvf1hn3Fi3T6Qp2lf7OrfR">>},{<<"newcookie">>,<<"A-vR5QgY9hu9BRrOWSMJPG5SCiTNOA94DyL5IVXvZZjouXPgP1S8MHeYpV2zik3PG9tK7eNGSKzh7BtFcB9JwVy5WtfQKxDMdvRxVfFL84ftgL6nuOFr_yHjw-GUwsWqSJLYPg">>},{<<"utmb">>,<<"111872281.6.10.1412029354">>},{<<"utmc">>,<<"111872281">>}],{response,200,[],[],[]}},undefined}],[]},{cowboy_websocket,handler_terminate,4,[{file,"src/cowboy_websocket.erl"},{line,761}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,529}]}]},{req,[{socket,#Port<0.3893>},{transport,ranch_tcp},{connection,keepalive},{pid,<0.214.0>},{method,<<"GET">>},{version,'HTTP/1.1'},{peer,{{127,0,0,1},36985}},{host,<<"localhost">>},{host_info,undefined},{port,8000},{path,<<"/about">>},{path_info,undefined},{qs,<<>>},{qs_vals,undefined},{bindings,[]},{headers,[{<<"host">>,<<"localhost:8000">>},{<<"user-agent">>,<<"Mozilla/5.0 (X11; Linux x8664; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.1.0">>},{<<"accept">>,<<"text/html,application/xhtml+xml,application/xml;q=0.9,/_;q=0.8">>},{<<"accept-language">>,<<"es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3">>},{<<"accept-encoding">>,<<"gzip, deflate">>},{<<"dnt">>,<<"1">>},{<<"sec-websocket-version">>,<<"13">>},{<<"origin">>,<<"http://localhost:8000">>},{<<"sec-websocket-key">>,<<"d+YikKQp6fvO+Q4mZl7Z8Q==">>},{<<"cookie">>,<<"utma=111872281.300584001.1406903199.1412004910.1412029354.10; utmz=111872281.1406903199.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); csrftoken=nI68lLnJ0Ctvf1hn3Fi3T6Qp2lf7OrfR; newcookie=A-vR5QgY9hu9BRrOWSMJPG5SCiTNOA94DyL5IVXvZZjouXPgP1S8MHeYpV2zik3PG9tK7eNGSKzh7BtFcB9JwVy5WtfQKxDMdvRxVfFL84ftgL6nuOFr_yHjw-GUwsWqSJLYPg; utmb=111872281.6.10.1412029354; utmc=111872281">>},{<<"connection">>,<<"keep-alive, Upgrade">>},{<<"pragma">>,<<"no-cache">>},{<<"cache-control">>,<<"no-cache">>},{<<"upgrade">>,<<"websocket">>}]},{p_headers,[{<<"upgrade">>,[<<"websocket">>]},{<<"connection">>,[<<"keep-alive">>,<<"upgrade">>]}]},{cookies,undefined},{meta,[{websocket_compress,false},{websocket_version,13}]},{body_state,waiting},{multipart,undefined},{buffer,<<>>},{resp_compress,false},{resp_state,done},{resp_headers,[]},{resp_body,<<>>},{onresponse,undefined}]},{state,{ws_state,nitrogen,{sbw,cowboy_simple_bridge,{cowboy_bridge,#Ref<0.0.0.311>},false,[],[],[],none,[{<<"host">>,<<"localhost:8000">>},{<<"user-agent">>,<<"Mozilla/5.0 (X11; Linux x8664; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.1.0">>},{<<"accept">>,<<"text/html,application/xhtml+xml,application/xml;q=0.9,/_;q=0.8">>},{<<"accept-language">>,<<"es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3">>},{<<"accept-encoding">>,<<"gzip, deflate">>},{<<"dnt">>,<<"1">>},{<<"sec-websocket-version">>,<<"13">>},{<<"origin">>,<<"http://localhost:8000">>},{<<"sec-websocket-key">>,<<"d+YikKQp6fvO+Q4mZl7Z8Q==">>},{<<"cookie">>,<<"utma=111872281.300584001.1406903199.1412004910.1412029354.10; utmz=111872281.1406903199.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); csrftoken=nI68lLnJ0Ctvf1hn3Fi3T6Qp2lf7OrfR; newcookie=A-vR5QgY9hu9BRrOWSMJPG5SCiTNOA94DyL5IVXvZZjouXPgP1S8MHeYpV2zik3PG9tK7eNGSKzh7BtFcB9JwVy5WtfQKxDMdvRxVfFL84ftgL6nuOFr_yHjw-GUwsWqSJLYPg; utmb=111872281.6.10.1412029354; utmc=111872281">>},{<<"connection">>,<<"keep-alive, Upgrade">>},{<<"pragma">>,<<"no-cache">>},{<<"cache-control">>,<<"no-cache">>},{<<"upgrade">>,<<"websocket">>}],[{<<"utma">>,<<"111872281.300584001.1406903199.1412004910.1412029354.10">>},{<<"utmz">>,<<"111872281.1406903199.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)">>},{<<"csrftoken">>,<<"nI68lLnJ0Ctvf1hn3Fi3T6Qp2lf7OrfR">>},{<<"newcookie">>,<<"A-vR5QgY9hu9BRrOWSMJPG5SCiTNOA94DyL5IVXvZZjouXPgP1S8MHeYpV2zik3PG9tK7eNGSKzh7BtFcB9JwVy5WtfQKxDMdvRxVfFL84ftgL6nuOFr_yHjw-GUwsWqSJLYPg">>},{<<"utmb">>,<<"111872281.6.10.1412029354">>},{<<"utmc">>,<<"111872281">>}],{response,200,[],[],[]}},undefined}},{terminate_reason,{remote,1001,<<>>}}],[{cowboy_websocket,handler_terminate,4,[{file,"src/cowboy_websocket.erl"},{line,763}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,529}]}]}

=ERROR REPORT==== 30-Sep-2014::01:01:07 === Error in process <0.214.0> on node 'myapp@127.0.0.1' with exit value: {[{reason,undef},{mfa,{cowboy_simple_bridge_anchor,websocket_terminate,3}},{stacktrace,[{cowboy_simple_bridge_anchor,websocket_terminate,[{remote,1001,<<0 bytes>>},{http_req,#Port<0.3893>,ranch_tcp,keepalive,<0.214.0>,<<3 bytes>>,'HTTP/1.1',{{127,0,0,1},36985},<<9 bytes>>,undefined...

The web pages work, but the error is launched in the console. This is the error in the browser:

TypeError: Obj.value is undefined return this.BINARY + this.int_to_bytes(Obj.value.length, 4) + Obj.value; bert.js (line 209, col 1)

choptastic commented 9 years ago

Alrighty, this is fixed. It was actually two separate issues. One of them was an issue with simple_bridge in cowboy (a improperly done ws_terminate function), and the other was in some javascript loading order in nitrogen in combination with nitrogen's jquery mobile stuff. Both are fixed and pushed into the mainline. Let me know if I missed something.