I'm using websockets with protocols to try and work with a javascript library bokehjs. This breaks when using chromium-based browsers although not with firefox.
You can reproduce the bug with
using HTTP.WebSockets
WebSockets.listen("127.0.0.1", 8081) do ws
for msg in ws
send(ws, msg)
end
end
then launching chrome or vivaldi and within its console, typing:
x = new WebSocket("ws://127.0.0.1:8081", ["my protocol"])
Note that everything works if we remove the second argument ["my protocol"]
console outputs: chromium
x = new WebSocket("ws://127.0.0.1:8081", ["aaa"])
WebSocket {url: 'ws://127.0.0.1:8081/', readyState: 0, bufferedAmount: 0, onopen: null, onerror: null, …}
VM3121:1 WebSocket connection to 'ws://127.0.0.1:8081/' failed:
(anonymous) @ VM3121:1
console outputs: julia
┌ LogLevel(-1): Listening on: 127.0.0.1:8081
└ @ HTTP.Servers ~/.julia/packages/HTTP/S5kNN/src/Servers.jl:364
┌ LogLevel(-1003): 👁 Start read: 🔗 0s 127.0.0.1:8081:8081 RawFD(22)
└ @ HTTP.ConnectionPool ~/.julia/packages/HTTP/S5kNN/src/ConnectionPool.jl:251
┌ LogLevel(-1001): startread called
└ @ HTTP.Servers ~/.julia/packages/HTTP/S5kNN/src/Servers.jl:425
┌ LogLevel(-1001): invoking handler
└ @ HTTP.Servers ~/.julia/packages/HTTP/S5kNN/src/Servers.jl:444
┌ LogLevel(-1002): Server websocket upgrade requested
└ @ HTTP.WebSockets ~/.julia/packages/HTTP/S5kNN/src/WebSockets.jl:420
┌ LogLevel(-1003): 👁 Start write:⏸ 1s 127.0.0.1:8081:8081 RawFD(22)
└ @ HTTP.ConnectionPool ~/.julia/packages/HTTP/S5kNN/src/ConnectionPool.jl:227
┌ LogLevel(-1002): 2086454f-a6d1-48c5-8df9-017b84521c8b: WebSocket upgraded; connection established
└ @ HTTP.WebSockets ~/.julia/packages/HTTP/S5kNN/src/WebSockets.jl:437
┌ LogLevel(-1002): 2086454f-a6d1-48c5-8df9-017b84521c8b: Reading message
└ @ HTTP.WebSockets ~/.julia/packages/HTTP/S5kNN/src/WebSockets.jl:656
┌ Error: 2086454f-a6d1-48c5-8df9-017b84521c8b: Unexpected websocket server error
│ (e, catch_backtrace()) =
│ EOFError: read end of file
│ Stacktrace:
│ [1] (::Base.var"#wait_locked#645")(s::Sockets.TCPSocket, buf::IOBuffer, nb::Int64)
│ @ Base ./stream.jl:892
│ [2] unsafe_read(s::Sockets.TCPSocket, p::Ptr{UInt8}, nb::UInt64)
│ @ Base ./stream.jl:900
│ [3] unsafe_read(c::HTTP.ConnectionPool.Connection, p::Ptr{UInt8}, n::UInt64)
│ @ HTTP.ConnectionPool ~/.julia/packages/HTTP/S5kNN/src/ConnectionPool.jl:173
│ [4] unsafe_read
│ @ ./io.jl:724 [inlined]
│ [5] unsafe_read(s::HTTP.ConnectionPool.Connection, p::Base.RefValue{UInt16}, n::Int64)
│ @ Base ./io.jl:723
│ [6] read!
│ @ ./io.jl:725 [inlined]
│ [7] read
│ @ ./io.jl:729 [inlined]
│ [8] readframe(io::HTTP.ConnectionPool.Connection, ::Type{HTTP.WebSockets.Frame}, buffer::Vector{UInt8}, first_fragment_opcode::HTTP.WebSockets.OpCode)
│ @ HTTP.WebSockets ~/.julia/packages/HTTP/S5kNN/src/WebSockets.jl:128
│ [9] readframe
│ @ ~/.julia/packages/HTTP/S5kNN/src/WebSockets.jl:127 [inlined]
│ [10] receive(ws::WebSocket)
│ @ HTTP.WebSockets ~/.julia/packages/HTTP/S5kNN/src/WebSockets.jl:658
│ [11] iterate(ws::WebSocket, st::Nothing)
│ @ HTTP.WebSockets ~/.julia/packages/HTTP/S5kNN/src/WebSockets.jl:697
│ [12] iterate
│ @ ~/.julia/packages/HTTP/S5kNN/src/WebSockets.jl:695 [inlined]
│ [13] (::var"#3#4")(ws::WebSocket)
│ @ Main ./REPL[4]:2
│ [14] upgrade(f::var"#3#4", http::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Connection}; suppress_close_error::Bool, maxframesize::Int64, maxfragmentation::Int64, kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
│ @ HTTP.WebSockets ~/.julia/packages/HTTP/S5kNN/src/WebSockets.jl:439
│ [15] upgrade
│ @ ~/.julia/packages/HTTP/S5kNN/src/WebSockets.jl:420 [inlined]
│ [16] (::HTTP.WebSockets.var"#8#9"{Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, var"#3#4"})(http::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Connection})
│ @ HTTP.WebSockets ~/.julia/packages/HTTP/S5kNN/src/WebSockets.jl:416
│ [17] #invokelatest#2
│ @ ./essentials.jl:716 [inlined]
│ [18] invokelatest
│ @ ./essentials.jl:714 [inlined]
│ [19] handle_connection(f::Function, c::HTTP.ConnectionPool.Connection, listener::HTTP.Servers.Listener{Nothing, Sockets.TCPServer}, readtimeout::Int64, access_log::Nothing)
│ @ HTTP.Servers ~/.julia/packages/HTTP/S5kNN/src/Servers.jl:445
│ [20] (::HTTP.Servers.var"#15#16"{HTTP.WebSockets.var"#8#9"{Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, var"#3#4"}, HTTP.Servers.Listener{Nothing, Sockets.TCPServer}, Set{HTTP.ConnectionPool.Connection}, Int64, Nothing, Base.Semaphore, HTTP.ConnectionPool.Connection})()
│ @ HTTP.Servers ./task.jl:423
└ @ HTTP.WebSockets ~/.julia/packages/HTTP/S5kNN/src/WebSockets.jl:442
┌ LogLevel(-1002): 2086454f-a6d1-48c5-8df9-017b84521c8b: Closing websocket
└ @ HTTP.WebSockets ~/.julia/packages/HTTP/S5kNN/src/WebSockets.jl:564
┌ LogLevel(-1002): 2086454f-a6d1-48c5-8df9-017b84521c8b: Reading message
└ @ HTTP.WebSockets ~/.julia/packages/HTTP/S5kNN/src/WebSockets.jl:656
┌ LogLevel(-1001): closeread
└ @ HTTP.Servers ~/.julia/packages/HTTP/S5kNN/src/Servers.jl:450
┌ LogLevel(-1003): ✉️ Read done: 💀 2s 127.0.0.1:8081:8081 RawFD(4294967295)
└ @ HTTP.ConnectionPool ~/.julia/packages/HTTP/S5kNN/src/ConnectionPool.jl:273
┌ LogLevel(-1001): closewrite
└ @ HTTP.Servers ~/.julia/packages/HTTP/S5kNN/src/Servers.jl:452
┌ LogLevel(-1003): 🗣 Write done: 💀 2s 127.0.0.1:8081:8081 RawFD(4294967295)
└ @ HTTP.ConnectionPool ~/.julia/packages/HTTP/S5kNN/src/ConnectionPool.jl:239
┌ LogLevel(-1001): ✋ "Connection: close": 💀 2s 127.0.0.1:8081:8081 RawFD(4294967295)
└ @ HTTP.Streams ~/.julia/packages/HTTP/S5kNN/src/Streams.jl:136
Versions
- Julia 1.7.2
- HTTP.jl 1.0.5
- MbedTLS.jl 1.0.3
Vivaldi browser
version | 5.3.2679.58 (Stable channel) stable (64-bit)
JavaScript | V8 10.2.154.8
User Agent | Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.125 Safari/537.36
Chrome browser
Version 102.0.5005.61 (Official Build) (64-bit)
Firefox browser
version 102.0 (ubuntu)
I'm using websockets with protocols to try and work with a javascript library bokehjs. This breaks when using chromium-based browsers although not with firefox.
You can reproduce the bug with
then launching chrome or vivaldi and within its console, typing:
Note that everything works if we remove the second argument
["my protocol"]console outputs: chromium
console outputs: julia
Versions
Vivaldi browser
version | 5.3.2679.58 (Stable channel) stable (64-bit)
JavaScript | V8 10.2.154.8
User Agent | Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.125 Safari/537.36
Chrome browser
Version 102.0.5005.61 (Official Build) (64-bit)
Firefox browser
version 102.0 (ubuntu)