Challenge - Serving WGLMakie plots with observables via Oxygen using a websocket connection to Bonito. The issue is that Oxygen serves a static image without observables. It appears that the initial Session ID from Bonito is being passed to Oxygen but not any subsequent updates associated with observables?
Welcome suggestions for how to enable observables for WGLMakie plots when served by Oxygen via a websocket connection to a running Bonito server which manages interactivity.
A code example is provided below. This code represents the section from app creation to server instantiation.
# Define the wglmakie visuals as a bonito app to enable observables using DataInspector
lregress_wgl = App() do session, request
DataInspector(fig_ols_inc_pre_tax_oxy)
return DOM.div(fig_ols_inc_pre_tax_oxy)
end
# Set up the active bonito.jl server with proxy url for Oxygen url
server_lregress = Bonito.Server(lregress_wgl, "127.0.0.1", 9389, proxy_url="http://localhost:8095/lregress")
route_name = "/" # define a route
route!(server_lregress, "$(route_name)" => lregress_wgl) # assign route to bonito.jl app
iframe_url = Bonito.online_url(server_lregress, "$(route_name)") # identify url created by bonito.jl
@info "Application URL: $iframe_url" # view assigned url in the terminal display
# Set up a websocket connection that forwards bonito session id to oxygen
@websocket "/{session_id}" function(ws::HTTP.WebSocket, session_id::String)
if haskey(server_lregress.sessions, session_id)
session = server_lregress.sessions[session_id]
Bonito.run_connection_loop(session, Bonito.WebSocketHandler(), ws)
else
@warn "Session $session_id not found"
close(ws)
end
end
# Route the bonito.jl global app using oxygen.jl web server
# This approach renders a static webpage.
# What is causing the bonito session_id updates not to forward to oxygen?
@get "/lregress" function()
return html(lregress_wgl)
end
# Start the Oxygen web server
serve(host="127.0.0.1", port=8095)