Skip to content

Commit 29a220e

Browse files
1 parent a18efa6 commit 29a220e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

docs/contrib/websocket/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,12 @@ cfg := Config{
142142
app.Get("/ws/:id", websocket.New(func(c *websocket.Conn) {}, cfg))
143143

144144

145-
```
145+
```
146+
147+
## Note for WebSocket subprotocols
148+
149+
The config `Subprotocols` only helps you negotiate subprotocols and sets a `Sec-Websocket-Protocol` header if it has a suitable subprotocol. For more about negotiates process, check the comment for `Subprotocols` in [fasthttp.Upgrader](https://pkg.go.dev/github.com/fasthttp/websocket#Upgrader) .
150+
151+
All connections will be sent to the handler function no matter whether the subprotocol negotiation is successful or not. You can get the selected subprotocol from `conn.Subprotocol()`.
152+
153+
If a connection includes the `Sec-Websocket-Protocol` header in the request but the protocol negotiation fails, the browser will immediately disconnect the connection after receiving the upgrade response.

0 commit comments

Comments
 (0)