Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix Mux integration. Use HTTP.WebSockets instead of Websockets.jl #515

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mkitti
Copy link

@mkitti mkitti commented Aug 19, 2024

This fixes the following error.

using Interact, Plots, Mux, WebIO, HTTP
begin
    mp = @manipulate throttle=.05 for λ=0:.1:5, μ=0:.1:5
        xs = range(0.0, 1.0, length = 100)
        Plots.plot(xs, x -> λ*x^2 + μ)
    end
    ui = dom"div"(mp)
    WebIO.webio_serve(page("/", req -> ui), 8006)
end

After navigating to http://localhost:8006 an error due to MethodError: no method matching isopen(::HTTP.WebSockets.WebSocket) would be generated.

Error handling websocket connection:
TaskFailedException
Stacktrace:
  [1] wait
    @ ./task.jl:352 [inlined]
  [2] create_socket(req::Dict{Any, Any})
    @ WebIO ~/.julia/packages/WebIO/8Xm9p/src/providers/mux.jl:47
  [3] #5
    @ ~/.julia/dev/Mux/src/Mux.jl:17 [inlined]
  [4] (::Mux.var"#1#2"{Mux.var"#5#6"{Mux.var"#29#30"{Vector{SubString{String}}}, typeof(WebIO.create_socket)}, Mux.var"#1#2"{typeof(Mux.wclose), Mux.var"#1#2"{Mux.var"#19#20"{Mux.var"#23#24"{Symbol, Int64}}, Mux.var"#21#22"{String}}}})(x::Dict{Any, Any})
    @ Mux ~/.julia/dev/Mux/src/Mux.jl:10
  [5] splitquery(app::Mux.var"#1#2"{Mux.var"#5#6"{Mux.var"#29#30"{Vector{SubString{String}}}, typeof(WebIO.create_socket)}, Mux.var"#1#2"{typeof(Mux.wclose), Mux.var"#1#2"{Mux.var"#19#20"{Mux.var"#23#24"{Symbol, Int64}}, Mux.var"#21#22"{String}}}}, req::Dict{Any, Any})
    @ Mux ~/.julia/dev/Mux/src/basics.jl:31
  [6] #1
    @ ~/.julia/dev/Mux/src/Mux.jl:10 [inlined]
  [7] wcatch(app::Mux.var"#1#2"{typeof(Mux.splitquery), Mux.var"#1#2"{Mux.var"#5#6"{Mux.var"#29#30"{Vector{SubString{String}}}, typeof(WebIO.create_socket)}, Mux.var"#1#2"{typeof(Mux.wclose), Mux.var"#1#2"{Mux.var"#19#20"{Mux.var"#23#24"{Symbol, Int64}}, Mux.var"#21#22"{String}}}}}, req::Dict{Any, Any})
    @ Mux ~/.julia/dev/Mux/src/websockets_integration.jl:11
  [8] #1
    @ ~/.julia/dev/Mux/src/Mux.jl:10 [inlined]
  [9] todict
    @ ~/.julia/dev/Mux/src/basics.jl:25 [inlined]
 [10] #3 (repeats 2 times)
    @ ~/.julia/dev/Mux/src/Mux.jl:14 [inlined]
 [11] (::Mux.var"#1#2"{Mux.var"#3#4"{Mux.var"#3#4"{typeof(Mux.todict), typeof(Mux.wcatch)}, typeof(Mux.splitquery)}, Mux.var"#1#2"{Mux.var"#5#6"{Mux.var"#29#30"{Vector{SubString{String}}}, typeof(WebIO.create_socket)}, Mux.var"#1#2"{typeof(Mux.wclose), Mux.var"#1#2"{Mux.var"#19#20"{Mux.var"#23#24"{Symbol, Int64}}, Mux.var"#21#22"{String}}}}})(x::HTTP.WebSockets.WebSocket)
    @ Mux ~/.julia/dev/Mux/src/Mux.jl:10
 [12] (::Mux.var"#9#10"{Mux.App})(sock::HTTP.WebSockets.WebSocket)
    @ Mux ~/.julia/dev/Mux/src/server.jl:48
 [13] upgrade(f::Mux.var"#9#10"{Mux.App}, http::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.Connections.Connection{Sockets.TCPSocket}}; suppress_close_error::Bool, maxframesize::Int64, maxfragmentation::Int64, nagle::Bool, quickack::Bool, kw::@Kwargs{})
    @ HTTP.WebSockets ~/.julia/packages/HTTP/sJD5V/src/WebSockets.jl:456
 [14] upgrade
    @ ~/.julia/packages/HTTP/sJD5V/src/WebSockets.jl:425 [inlined]
 [15] (::Mux.var"#14#15"{Mux.App, Mux.App})(http::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.Connections.Connection{Sockets.TCPSocket}})
    @ Mux ~/.julia/dev/Mux/src/server.jl:81
 [16] #invokelatest#2
    @ ./essentials.jl:892 [inlined]
 [17] invokelatest
    @ ./essentials.jl:889 [inlined]
 [18] handle_connection(f::Function, c::HTTP.Connections.Connection{Sockets.TCPSocket}, listener::HTTP.Servers.Listener{Nothing, Sockets.TCPServer}, readtimeout::Int64, access_log::Nothing)
    @ HTTP.Servers ~/.julia/packages/HTTP/sJD5V/src/Servers.jl:469
 [19] (::HTTP.Servers.var"#16#17"{Mux.var"#14#15"{Mux.App, Mux.App}, HTTP.Servers.Listener{Nothing, Sockets.TCPServer}, Set{HTTP.Connections.Connection}, Int64, Nothing, ReentrantLock, Base.Semaphore, HTTP.Connections.Connection{Sockets.TCPSocket}})()
    @ HTTP.Servers ~/.julia/packages/HTTP/sJD5V/src/Servers.jl:401

    nested task error: MethodError: no method matching isopen(::HTTP.WebSockets.WebSocket)
    
    Closest candidates are:
      isopen(::Base.Filesystem.File)
       @ Base filesystem.jl:128
      isopen(::Mmap.Anonymous)
       @ Mmap ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/Mmap/src/Mmap.jl:45
      isopen(::SimpleBufferStream.BufferStream)
       @ SimpleBufferStream ~/.julia/packages/SimpleBufferStream/N1BA4/src/BufferStream.jl:30
      ...
    
    Stacktrace:
     [1] (::WebIO.var"#98#99"{WebIO.WebSockConnection, HTTP.WebSockets.WebSocket})()
       @ WebIO ~/.julia/packages/WebIO/8Xm9p/src/providers/mux.jl:40

@mkitti
Copy link
Author

mkitti commented Aug 19, 2024

Need to write and fix tests to get out of draft.

@mkitti
Copy link
Author

mkitti commented Aug 19, 2024

I also suspect that we need to remove all the WebSockets.jl dependency and switch to HTTP.WebSockets.

@mkitti mkitti marked this pull request as ready for review August 19, 2024 04:57
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug in interaction with Mux.jl
1 participant