Odd Mux.jl + Interact.jl behavior: widget only works in "/" but not pages within such as "/page1"


#1

I swear this was working fine a couple weeks ago and I didn’t think I upgraded anything, but I put together this example code that does not work the way I would expect. The same Interact.jl widget, when accessed from app1 at “/” prints “clicked” to the terminal when accessed through the localhost in chrome, while app2 at “/page1” does not respond when the same button is clicked.

Running Julia 1.0.2, Mux v0.5.3 and Interact v0.9.0 locally and on my aws server. An error does appear occasionally when navigating to “/page1”, but not savvy enough on the server side of things to understand why it would selectively affect the widget only on /page1.

Any help would be appreciated, design solutions included, and happy to open an issue in Mux.jl if the solution isn’t obvious to anyone. Thank you! -Andrew

Error:

Error handling websocket connection: WebSockets.WebSocketClosedError(“ws|server respond to OPCODE_CLOSE 1001:Going Away”)"

Example code:

using Mux, Interact                                                                                                                                                       
                                                                                                                                                                                  
 # setting up Interact.jl widget                                                                                                                                                  
 b = button("Test click")                                                                                                                                                         
 on(n -> println("clicked"), b)                                                                                                                                        
                                                                                                                                                                                  
 # putting together apps for root and id1 page using same widget                                                                                                                  
 app1 = page("/", req -> b)                                                                                                                                                    
 app2 = page("/page1", req -> b)                                                                                                                                                       
                                                                                                                                                                                  
 # stacking together                                                                                                                                                              
 app = Mux.stack(app1, app2)                                                                                                                                                 
                                                                                                                                                                                  
 # serving                                                                                                                                                                        
 WebIO.webio_serve(app, 8000)  

#2

For the curious: decided to open an issue over at Mux.jl and currently following up with the help of hustf: https://github.com/JuliaWeb/Mux.jl/issues/80


#3

I found that WebIO.webio_serve() was only functional at “/” try specifying telling mux a route to “/” instead or the “/web_socket” that webio_serve is using:

wsapp = Mux.App(Mux.mux(Mux.wdefaults,
                        Mux.route("/", WebIO.create_socket),
                        Mux.wclose,
                        Mux.notfound()
                        ))
 Mux.serve(app, wsapp, host, port)