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
Refactor the websocket handling in Nova #161
Conversation
The current implementation of websockets have a big flaw which will crash the flow if a post-plugin is used. This commits fix this aswell as integrating the websocket-flow in Novas generic way with handlers.
…'t exported in the handler-module
It looks ok, but I will test it with my test app and see if websocket works. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> > 2021-12-30T14:14:19.693001+01:00 error: Ranch listener nova_listener had connection process started with cowboy_clear:start_link/4 at <0.2416.0> exit with reason: {function_clause,[{nova_ws_handler,terminate,[{crash,error,function_clause},#{host => <<"localhost">>,method => <<"GET">>,path => <<"/ws/wohoo">>,peer => {{127,0,0,1},58506},port => 8080,qs => <<>>,scheme => <<"http">>,version => 'HTTP/1.1'},{ok,#{controller_data => <<"wohoo">>,mod => nova_request_ws,module => nova_request_ws,plugins => [{pre_request,[{nova_request_plugin,#{decode_json_body => true,parse_qs => true,read_urlencoded_body => true}}]}]}}],[{file,"/home/daniel/project/nova_request_app/_build/default/lib/nova/src/nova_ws_handler.erl"},{line,67}]},{cowboy_websocket,handler_call,6,[{file,"/home/daniel/project/nova_request_app/_build/default/lib/cowboy/src/cowboy_websocket.erl"},{line,564}]},{cowboy_http,loop,1,[{file,"/home/daniel/project/nova_request_app/_build/default/lib/cowboy/src/cowboy_http.erl"},{line,257}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}```
Got a crash
@Taure Made a new commit on this. Updated our flow in how we are handling the result of a websocket-request. According to cowboy 2.7 the proper response is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix dialyzer warnings and we can merge this
I realized that the websocket plugins wouldn't work with the previous implementation so I sat down and rewrote parts of it. I also incorporated the handler-idea into websockets aswell.