# Websockets invalid value for Enum OpCode

**URL:** <https://discourse.julialang.org/t/websockets-invalid-value-for-enum-opcode/128335>\
**Category:** Web Stack\
**Created:** [April 23, 2025, 3:34pm UTC](https://discourse.julialang.org/t/websockets-invalid-value-for-enum-opcode/128335 "2025-04-23T15:34:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![freeman](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@freeman](https://discourse.julialang.org/u/freeman)\
**Post date:** [April 23, 2025, 3:34pm UTC](https://discourse.julialang.org/t/websockets-invalid-value-for-enum-opcode/128335/1 "2025-04-23T15:34:50Z")

</div>

Just flagging that this happened out in the wild.

```julia
│ e = ArgumentError: invalid value for Enum OpCode: 11                                                                                                                                                                                                                                  
│ stacktrace =                                                                                                                                                                                                                                                                          
│ 11-element Vector{Base.StackTraces.StackFrame}:                                                                                                                                                                                                                                      
│ enum_argument_error(typename::Symbol, x::UInt8) at Enums.jl:93                                                                                                                                                                                                                      
│ OpCode at Enums.jl:212 [inlined]                                                                                                                                                                                                                                                    
│ getproperty at WebSockets.jl:41 [inlined]                                                                                              
│ readframe(io::HTTP.Connections.Connection{OpenSSL.SSLStream}, ::Type{HTTP.WebSockets.Frame}, buffer::Vector{UInt8}, first_fragment_opcode::HTTP.WebSockets.OpCode) at WebSockets.jl:154                                                                                             
│ readframe(io::HTTP.Connections.Connection{OpenSSL.SSLStream}, ::Type{HTTP.WebSockets.Frame}, buffer::Vector{UInt8}) at WebSockets.jl:128                                                                                                                                            
│ receive(ws::HTTP.WebSockets.WebSocket) at WebSockets.jl:683                                                                                                                                                                                                                         
│ iterate(ws::HTTP.WebSockets.WebSocket, st::Nothing) at WebSockets.jl:722                                                                                                                                                                                                            
│ iterate at WebSockets.jl:720 [inlined]                                                                                                            

```

I have no way to reproduce.

> <https://github.com/JuliaWeb/HTTP.jl/blob/ef9a169c5471e14558409a649057d773c09451f6/src/WebSockets.jl#L25>

From the spec it appears this should never happen:

> **[RFC 6455: The WebSocket Protocol](https://www.rfc-editor.org/rfc/rfc6455#page-66)**

I’m using `HTTP v1.10.16`.

Anyone has an idea what this could mean? Serverside bug?

---

<div class="post-metadata">

**Author:** ![simsurace](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simsurace/32/30216_2.png) [@simsurace](https://discourse.julialang.org/u/simsurace)\
**Post date:** [April 23, 2025, 6:54pm UTC](https://discourse.julialang.org/t/websockets-invalid-value-for-enum-opcode/128335/2 "2025-04-23T18:54:16Z")

</div>

Looking at [RFC 6455: The WebSocket Protocol](https://www.rfc-editor.org/rfc/rfc6455#page-29) it seems that 11-15 are not illegal, it says they are „are reserved for further control frames“. I‘m not sure if this would qualify as a bug in HTTP.jl. I would suggest to open an issue there.

EDIT: after a bit more thought, I think the above means that the reserved codes (3-7 and 11-15) are reserved for future extensions, so failing the connection would actually be the expected behavior here. Did the WS connection close after the error occurred?
