# Serving WGLMakie Plots with Observables via Oxygen Server Having Websocket Connection to Bonito

**URL:** <https://discourse.julialang.org/t/serving-wglmakie-plots-with-observables-via-oxygen-server-having-websocket-connection-to-bonito/136764>\
**Category:** General Usage\
**Tags:** plotting, makie, wglmakie, oxygenjl\
**Created:** [April 18, 2026, 1:05pm UTC](https://discourse.julialang.org/t/serving-wglmakie-plots-with-observables-via-oxygen-server-having-websocket-connection-to-bonito/136764 "2026-04-18T13:05:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sumfun](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@Sumfun](https://discourse.julialang.org/u/Sumfun)\
**Post date:** [April 18, 2026, 1:05pm UTC](https://discourse.julialang.org/t/serving-wglmakie-plots-with-observables-via-oxygen-server-having-websocket-connection-to-bonito/136764/1 "2026-04-18T13:05:21Z")

</div>

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.

```julia-auto
# 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) 

```

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [April 18, 2026, 1:13pm UTC](https://discourse.julialang.org/t/serving-wglmakie-plots-with-observables-via-oxygen-server-having-websocket-connection-to-bonito/136764/2 "2026-04-18T13:13:51Z")

</div>

Why not use pure Bonito for the server etc?

---

<div class="post-metadata">

**Author:** ![Sumfun](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@Sumfun](https://discourse.julialang.org/u/Sumfun)\
**Post date:** [April 18, 2026, 1:50pm UTC](https://discourse.julialang.org/t/serving-wglmakie-plots-with-observables-via-oxygen-server-having-websocket-connection-to-bonito/136764/3 "2026-04-18T13:50:58Z")

</div>

Because I have multiple interactions between the UI and other Julia-based engines, and am using Oxygen as the middleware to manage all interactions with the UI.

---

<div class="post-metadata">

**Author:** ![Sumfun](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@Sumfun](https://discourse.julialang.org/u/Sumfun)\
**Post date:** [April 18, 2026, 11:48pm UTC](https://discourse.julialang.org/t/serving-wglmakie-plots-with-observables-via-oxygen-server-having-websocket-connection-to-bonito/136764/4 "2026-04-18T23:48:18Z")

</div>

With lots of I/O, Oxygen.jl is easy to use, nice syntax. I have many interactions that go beyond just plots. WGLMakie is a super package, but why not integrate with other packages? Why can’t bonito.jl pass a simple session\_id to oxygen.jl? Can you help?
