You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using Mux.jl master, WebIO from #169 , HTTP.jl master, and WebSockets with JuliaWeb/WebSockets.jl#106 I think things are very close to working.
However, websocket connections from the browser still don't work. I think this is a minimal example that reproduces the error:
using WebIO
using JSON
using Sockets
using Mux
struct WebSockConnection <: WebIO.AbstractConnection
sock
end
function Sockets.send(p::WebSockConnection, data)
write(p.sock, sprint(io->JSON.print(io,data)))
end
Base.isopen(p::WebSockConnection) = isopen(p.sock)
function create_socket(req)
@show req
sock = req[:socket]
conn = WebSockConnection(sock)
t = @async while isopen(sock)
data = read(sock)
msg = JSON.parse(String(data))
WebIO.dispatch(conn, msg)
end
wait(t)
end
websock = Mux.App(Mux.mux(
Mux.wdefaults,
Mux.route("/webio-socket", create_socket),
Mux.wclose,
Mux.notfound(),
))
port = 8005
Mux.serve(websock, port)
Just run the above lines, then, in a JS console, try to execute: ws = new WebSocket("ws://localhost:8005/webio-socket")
I see the following error message (in Julia) when I do that:
Error handling websocket connection:
KeyError: key :socket not found
Stacktrace:
[1] getindex at ./dict.jl:478 [inlined]
[2] macro expansion at ./show.jl:556 [inlined]
[3] create_socket(::Dict{Any,Any}) at /home/rdeits/.julia/dev/WebIO/mux-ws-test.jl:17
[4] (::getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##27#28")){Array{SubString{String},1}},typeof(create_socket)})(::Function, ::Dict{Any,Any}) at /home/rdeits/.julia/dev/Mux/src/Mux.jl:18
[5] #1 at /home/rdeits/.julia/dev/Mux/src/Mux.jl:11 [inlined]
[6] splitquery(::getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##27#28")){Array{SubString{String},1}},typeof(create_socket)},getfield(Mux, Symbol("##1#2")){typeof(Mux.wclose),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/rdeits/.julia/dev/Mux/src/basics.jl:32
[7] #1 at /home/rdeits/.julia/dev/Mux/src/Mux.jl:11 [inlined]
[8] wcatch(::getfield(Mux, Symbol("##1#2")){typeof(Mux.splitquery),getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##27#28")){Array{SubString{String},1}},typeof(create_socket)},getfield(Mux, Symbol("##1#2")){typeof(Mux.wclose),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/rdeits/.julia/dev/Mux/src/websockets_integration.jl:12
[9] #1 at /home/rdeits/.julia/dev/Mux/src/Mux.jl:11 [inlined]
[10] todict(::getfield(Mux, Symbol("##1#2")){typeof(Mux.wcatch),getfield(Mux, Symbol("##1#2")){typeof(Mux.splitquery),getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##27#28")){Array{SubString{String},1}},typeof(create_socket)},getfield(Mux, Symbol("##1#2")){typeof(Mux.wclose),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/rdeits/.julia/dev/Mux/src/basics.jl:23
[11] #3 at /home/rdeits/.julia/dev/Mux/src/Mux.jl:15 [inlined] (repeats 2 times)
[12] (::getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##3#4")){getfield(Mux, Symbol("##3#4")){typeof(Mux.todict),typeof(Mux.wcatch)},typeof(Mux.splitquery)},getfield(Mux, Symbol("##1#2")){getfield(Mux, Symbol("##5#6")){getfield(Mux, Symbol("##27#28")){Array{SubString{String},1}},typeof(create_socket)},getfield(Mux, Symbol("##1#2")){typeof(Mux.wclose),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/rdeits/.julia/dev/Mux/src/Mux.jl:11
[13] (::getfield(Mux, Symbol("##7#8")){Mux.App})(::HTTP.Messages.Request) at /home/rdeits/.julia/dev/Mux/src/server.jl:42
[14] handle at /home/rdeits/.julia/dev/HTTP/src/Handlers.jl:35 [inlined]
[15] #7 at /home/rdeits/.julia/dev/HTTP/src/Servers.jl:170 [inlined]
[16] handle_request(::getfield(HTTP.Servers, Symbol("##7#11")){HTTP.Servers.Server{HTTP.Servers.http,HTTP.Handlers.HandlerFunction{getfield(Mux, Symbol("##7#8")){Mux.App}}}}, ::HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{TCPSocket}}) at /home/rdeits/.julia/dev/HTTP/src/Servers.jl:525
[17] handle_stream(::getfield(HTTP.Servers, Symbol("##7#11")){HTTP.Servers.Server{HTTP.Servers.http,HTTP.Handlers.HandlerFunction{getfield(Mux, Symbol("##7#8")){Mux.App}}}}, ::HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{TCPSocket}}) at /home/rdeits/.julia/dev/HTTP/src/Servers.jl:501
[18] (::getfield(HTTP.Servers, Symbol("##54#55")){getfield(HTTP.Servers, Symbol("##7#11")){HTTP.Servers.Server{HTTP.Servers.http,HTTP.Handlers.HandlerFunction{getfield(Mux, Symbol("##7#8")){Mux.App}}}},HTTP.ConnectionPool.Transaction{TCPSocket},HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{TCPSocket}}})() at ./task.jl:262┌ Error: (MethodError(convert, (HTTP.Messages.Response, nothing), 0x0000000000006c70), Base.StackTraces.StackFrame[setproperty!(::Request, ::Symbol, ::Nothing) at sysimg.jl:19, handle_request(::##7#11{Server{http,HandlerFunction{##7#8{App}}}}, ::Stream{Request,Transaction{TCPSocket}}) at Servers.jl:525, handle_stream(::##7#11{Server{http,HandlerFunction{##7#8{App}}}}, ::Stream{Request,Transaction{TCPSocket}}) at Servers.jl:501, (::##54#55{##7#11{Server{http,HandlerFunction{##7#8{App}}}},Transaction{TCPSocket},Stream{Request,Transaction{TCPSocket}}})() at task.jl:262])
We're expecting the req to contain a socket entry, but it doesn't (it's only keys are: Any[:query, :method, :params, :path, :data, :headers]). Maybe this is something that changed in the new HTTP.jl upgrade?
The text was updated successfully, but these errors were encountered:
Using Mux.jl master, WebIO from #169 , HTTP.jl master, and WebSockets with JuliaWeb/WebSockets.jl#106 I think things are very close to working.
However, websocket connections from the browser still don't work. I think this is a minimal example that reproduces the error:
Just run the above lines, then, in a JS console, try to execute:
ws = new WebSocket("ws://localhost:8005/webio-socket")
I see the following error message (in Julia) when I do that:
We're expecting the
req
to contain asocket
entry, but it doesn't (it's only keys are:Any[:query, :method, :params, :path, :data, :headers]
). Maybe this is something that changed in the new HTTP.jl upgrade?The text was updated successfully, but these errors were encountered: