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

WIP add websocket support #64

Merged
merged 9 commits into from
Aug 11, 2018
Merged

WIP add websocket support #64

merged 9 commits into from
Aug 11, 2018

Conversation

piever
Copy link
Collaborator

@piever piever commented Jul 21, 2018

An attempt to fix #63. I don't actually have examples of this working as it relies on WebSockets also updating to Julia 0.7. At the very least the websocket method of serve doesn't give method error anymore.

@codecov-io
Copy link

codecov-io commented Jul 21, 2018

Codecov Report

Merging #64 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #64   +/-   ##
=======================================
  Coverage   90.56%   90.56%           
=======================================
  Files           5        5           
  Lines          53       53           
=======================================
  Hits           48       48           
  Misses          5        5
Impacted Files Coverage Δ
src/Mux.jl 100% <ø> (ø) ⬆️
src/server.jl 100% <ø> (ø) ⬆️
src/basics.jl 79.16% <ø> (ø) ⬆️
src/routing.jl 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update edd4c67...43656b4. Read the comment docs.

@piever
Copy link
Collaborator Author

piever commented Jul 21, 2018

Would be happy to get some help as I'm a bit stuck though. On the testcase of #63 I get:

MethodError: no method matching (::getfield(Main, Symbol("##5#6")))(::getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##17#18")){getfield(Mux, Symbol("##21#22")){Symbol,Int64}},getfield(Mux, Symbol("##19#20")){String}}, ::Dict{Any,Any})
Closest candidates are:
  #5(::Any) at REPL[4]:1
Stacktrace:
 [1] (::getfield(Mux, Symbol("##1#2")){getfield(Main, Symbol("##5#6")),getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##17#18")){getfield(Mux, Symbol("##21#22")){Symbol,Int64}},getfield(Mux, Symbol("##19#20")){String}}})(::Dict{Any,Any}) at /home/pietro/.julia/dev/Mux/src/Mux.jl:11
 [2] #5 at /home/pietro/.julia/dev/Mux/src/Mux.jl:18 [inlined]
 [3] (::getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##27#28")){Array{SubString{String},1}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##40#43")){Bool,getfield(Mux, Symbol("#absdir#42")){Array{String,1}}},getfield(Mux, Symbol("##41#44")){getfield(Mux, Symbol("#absdir#42")){Array{String,1}}}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##17#18")){getfield(Mux, Symbol("##21#22")){Symbol,Int64}},getfield(Mux, Symbol("##19#20")){String}}}},getfield(Mux, Symbol("##1#2")){getfield(Main, Symbol("##5#6")),getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##17#18")){getfield(Mux, Symbol("##21#22")){Symbol,Int64}},getfield(Mux, Symbol("##19#20")){String}}}})(::Dict{Any,Any}) at /home/pietro/.julia/dev/Mux/src/Mux.jl:11
 [4] #5 at /home/pietro/.julia/dev/Mux/src/Mux.jl:18 [inlined]
 [5] #1 at /home/pietro/.julia/dev/Mux/src/Mux.jl:11 [inlined]
 [6] toresponse(::getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##27#28")){Array{SubString{String},1}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##45#48")){Bool,getfield(Mux, Symbol("#absdir#47"))},getfield(Mux, Symbol("##46#49")){getfield(Mux, Symbol("#absdir#47"))}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##17#18")){getfield(Mux, Symbol("##21#22")){Symbol,Int64}},getfield(Mux, Symbol("##19#20")){String}}}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##27#28")){Array{SubString{String},1}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##40#43")){Bool,getfield(Mux, Symbol("#absdir#42")){Array{String,1}}},getfield(Mux, Symbol("##41#44")){getfield(Mux, Symbol("#absdir#42")){Array{String,1}}}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##17#18")){getfield(Mux, Symbol("##21#22")){Symbol,Int64}},getfield(Mux, Symbol("##19#20")){String}}}},getfield(Mux, Symbol("##1#2")){getfield(Main, Symbol("##5#6")),getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##17#18")){getfield(Mux, Symbol("##21#22")){Symbol,Int64}},getfield(Mux, Symbol("##19#20")){String}}}}}, ::Dict{Any,Any}) at /home/pietro/.julia/dev/Mux/src/basics.jl:50
 [7] #1 at /home/pietro/.julia/dev/Mux/src/Mux.jl:11 [inlined]
 [8] splitquery(::getfield(Mux, Symbol("##1#2")){typeof(Mux.toresponse),getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##27#28")){Array{SubString{String},1}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##45#48")){Bool,getfield(Mux, Symbol("#absdir#47"))},getfield(Mux, Symbol("##46#49")){getfield(Mux, Symbol("#absdir#47"))}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##17#18")){getfield(Mux, Symbol("##21#22")){Symbol,Int64}},getfield(Mux, Symbol("##19#20")){String}}}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##27#28")){Array{SubString{String},1}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##40#43")){Bool,getfield(Mux, Symbol("#absdir#42")){Array{String,1}}},getfield(Mux, Symbol("##41#44")){getfield(Mux, Symbol("#absdir#42")){Array{String,1}}}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##17#18")){getfield(Mux, Symbol("##21#22")){Symbol,Int64}},getfield(Mux, Symbol("##19#20")){String}}}},getfield(Mux, Symbol("##1#2")){getfield(Main, Symbol("##5#6")),getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##17#18")){getfield(Mux, Symbol("##21#22")){Symbol,Int64}},getfield(Mux, Symbol("##19#20")){String}}}}}}, ::Dict{Any,Any}) at /home/pietro/.julia/dev/Mux/src/basics.jl:32
 [9] #1 at /home/pietro/.julia/dev/Mux/src/Mux.jl:11 [inlined]
 [10] basiccatch(::getfield(Mux, Symbol("##1#2")){typeof(Mux.splitquery),getfield(Mux, Symbol("##1#2")){typeof(Mux.toresponse),getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##27#28")){Array{SubString{String},1}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##45#48")){Bool,getfield(Mux, Symbol("#absdir#47"))},getfield(Mux, Symbol("##46#49")){getfield(Mux, Symbol("#absdir#47"))}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##17#18")){getfield(Mux, Symbol("##21#22")){Symbol,Int64}},getfield(Mux, Symbol("##19#20")){String}}}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##27#28")){Array{SubString{String},1}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##40#43")){Bool,getfield(Mux, Symbol("#absdir#42")){Array{String,1}}},getfield(Mux, Symbol("##41#44")){getfield(Mux, Symbol("#absdir#42")){Array{String,1}}}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##17#18")){getfield(Mux, Symbol("##21#22")){Symbol,Int64}},getfield(Mux, Symbol("##19#20")){String}}}},getfield(Mux, Symbol("##1#2")){getfield(Main, Symbol("##5#6")),getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##17#18")){getfield(Mux, Symbol("##21#22")){Symbol,Int64}},getfield(Mux, Symbol("##19#20")){String}}}}}}}, ::Dict{Any,Any}) at /home/pietro/.julia/dev/Mux/src/basics.jl:81
 [11] #1 at /home/pietro/.julia/dev/Mux/src/Mux.jl:11 [inlined]
 [12] todict(::getfield(Mux, Symbol("##1#2")){typeof(Mux.basiccatch),getfield(Mux, Symbol("##1#2")){typeof(Mux.splitquery),getfield(Mux, Symbol("##1#2")){typeof(Mux.toresponse),getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##27#28")){Array{SubString{String},1}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##45#48")){Bool,getfield(Mux, Symbol("#absdir#47"))},getfield(Mux, Symbol("##46#49")){getfield(Mux, Symbol("#absdir#47"))}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##17#18")){getfield(Mux, Symbol("##21#22")){Symbol,Int64}},getfield(Mux, Symbol("##19#20")){String}}}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##27#28")){Array{SubString{String},1}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##40#43")){Bool,getfield(Mux, Symbol("#absdir#42")){Array{String,1}}},getfield(Mux, Symbol("##41#44")){getfield(Mux, Symbol("#absdir#42")){Array{String,1}}}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##17#18")){getfield(Mux, Symbol("##21#22")){Symbol,Int64}},getfield(Mux, Symbol("##19#20")){String}}}},getfield(Mux, Symbol("##1#2")){getfield(Main, Symbol("##5#6")),getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##17#18")){getfield(Mux, Symbol("##21#22")){Symbol,Int64}},getfield(Mux, Symbol("##19#20")){String}}}}}}}}, ::HTTP.Messages.Request) at /home/pietro/.julia/dev/Mux/src/basics.jl:23
 [13] (::getfield(Mux, Symbol("##3#4")){typeof(Mux.todict),typeof(Mux.basiccatch)})(::Function, ::HTTP.Messages.Request) at /home/pietro/.julia/dev/Mux/src/Mux.jl:15 (repeats 5 times)
 [14] (::getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##3#4")){getfield(Mux, Symbol("##3#4")){getfield(Mux, Symbol("##3#4")){getfield(Mux, Symbol("##3#4")){getfield(Mux, Symbol("##3#4")){typeof(Mux.todict),typeof(Mux.basiccatch)},typeof(Mux.splitquery)},typeof(Mux.toresponse)},getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##27#28")){Array{SubString{String},1}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##45#48")){Bool,getfield(Mux, Symbol("#absdir#47"))},getfield(Mux, Symbol("##46#49")){getfield(Mux, Symbol("#absdir#47"))}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##17#18")){getfield(Mux, Symbol("##21#22")){Symbol,Int64}},getfield(Mux, Symbol("##19#20")){String}}}}},getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##27#28")){Array{SubString{String},1}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##40#43")){Bool,getfield(Mux, Symbol("#absdir#42")){Array{String,1}}},getfield(Mux, Symbol("##41#44")){getfield(Mux, Symbol("#absdir#42")){Array{String,1}}}},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##17#18")){getfield(Mux, Symbol("##21#22")){Symbol,Int64}},getfield(Mux, Symbol("##19#20")){String}}}}},getfield(Mux, Symbol("##1#2")){getfield(Main, Symbol("##5#6")),getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##17#18")){getfield(Mux, Symbol("##21#22")){Symbol,Int64}},getfield(Mux, Symbol("##19#20")){String}}}})(::HTTP.Messages.Request) at /home/pietro/.julia/dev/Mux/src/Mux.jl:11
 [15] (::getfield(Mux, Symbol("##7#8")){Mux.App})(::HTTP.Messages.Request) at /home/pietro/.julia/dev/Mux/src/server.jl:42
 [16] handle_request(::getfield(Mux, Symbol("##7#8")){Mux.App}, ::HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) at /home/pietro/.julia/dev/HTTP/src/Servers.jl:525
 [17] (::getfield(WebSockets, Symbol("##27#31")){WebSockets.ServerWS{HTTP.Servers.http,HTTP.Handlers.HandlerFunction{getfield(Mux, Symbol("##7#8")){Mux.App}},WebSockets.WebsocketHandler{getfield(Mux, Symbol("##9#10")){Mux.App}}}})(::HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) at /home/pietro/.julia/dev/WebSockets/src/HTTP.jl:320
 [18] handle_stream(::getfield(WebSockets, Symbol("##27#31")){WebSockets.ServerWS{HTTP.Servers.http,HTTP.Handlers.HandlerFunction{getfield(Mux, Symbol("##7#8")){Mux.App}},WebSockets.WebsocketHandler{getfield(Mux, Symbol("##9#10")){Mux.App}}}}, ::HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) at /home/pietro/.julia/dev/HTTP/src/Servers.jl:499
 [19] (::getfield(HTTP.Servers, Symbol("##54#55")){getfield(WebSockets, Symbol("##27#31")){WebSockets.ServerWS{HTTP.Servers.http,HTTP.Handlers.HandlerFunction{getfield(Mux, Symbol("##7#8")){Mux.App}},WebSockets.WebsocketHandler{getfield(Mux, Symbol("##9#10")){Mux.App}}}},HTTP.ConnectionPool.Transaction{Sockets.TCPSocket},HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}})() at ./task.jl:262

@MikeInnes
Copy link
Collaborator

Looks like this handler function should take two args, as it did originally?

Copy link

@hustf hustf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delayed upgrade of Websockets. I hope to get time for that next week. If you choose to use Websockets, I recommend readprotected and writeprotected. It reduces your error handling and makes error messages more readable. I believe this is already working on the branch for 0.7.

@piever
Copy link
Collaborator Author

piever commented Jul 26, 2018

I've changed the handler back to how it was but it doesn't seem to fix the problem, I get exactly the same error. I feel that wdefault doesn't work properly in the new framework but I'm not sure why.

EDIT: actually it's a different problem, wdefault doesn't even get called, not sure why.

@hustf thanks for the tip. Where exactly should I switch to readguarded ? It seems that only the echo function uses read or write but it's not used in the code that's being tested here.

@hustf
Copy link

hustf commented Jul 26, 2018 via email

@hustf
Copy link

hustf commented Aug 4, 2018

Sorry for the missing follow up from my side. Time ran out, and next week is juliacon...

@rdeits
Copy link
Collaborator

rdeits commented Aug 8, 2018

Any updates on this? Or anyone want to hack on it while we're at JuliaCon 🙂 ?

@piever
Copy link
Collaborator Author

piever commented Aug 8, 2018

I'm still stuck... Maybe we could try to fix this during the Hackathon?

@rdeits
Copy link
Collaborator

rdeits commented Aug 9, 2018

Count me in

@shashi shashi merged commit 43656b4 into JuliaWeb:master Aug 11, 2018
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

Successfully merging this pull request may close these issues.

Help with breaking changes in Mux.serve on 0.7
6 participants