Skip to content

Commit f7225f1

Browse files
committed
Change subprotocol names
Use domain names, as suggested in https://www.rfc-editor.org/rfc/rfc6455#section-1.9. As documented in https://www.rfc-editor.org/rfc/rfc6455#section-4.1, `/` isn't valid in a subprotocol name. (This restriction is enforced by the ws package; see https://github.com/websockets/ws/blob/8.5.0/lib/websocket.js#L34.)
1 parent 743217e commit f7225f1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const WebSocket = require("ws")
105105
websocket: {
106106
only: true,
107107
initially: true,
108-
subprotocol: "quux/1.0",
108+
subprotocol: "quux.example.com",
109109
connect: ({ ctx, ws }) => {
110110
ctx.to = setInterval(() => {
111111
if (ws.readyState === WebSocket.OPEN)
@@ -210,7 +210,7 @@ $ wscat --connect ws://127.0.0.1:12345/baz
210210
< {"at":"baz","seen":{"foo":7}}
211211

212212
# access the full-featured exclusive WebSocket route via WebSockets
213-
$ wscat --subprotocol "quux/1.0" --auth foo:bar --connect ws://127.0.0.1:12345/quux
213+
$ wscat --subprotocol "quux.example.com" --auth foo:bar --connect ws://127.0.0.1:12345/quux
214214
< {"cmd":"HELLO",arg:"foo"}
215215
> {"cmd":"PING"}
216216
< {"result":"PONG"}
@@ -281,7 +281,7 @@ server.route({
281281
websocket: {
282282
only: true,
283283
autoping: 10 * 1000,
284-
subprotocol: "foo/1.0",
284+
subprotocol: "v1.foo.example.com",
285285
initially: true,
286286
connect: ({ ctx, wss, ws, req, peers }) => {
287287
...

sample-server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const WebSocket = require("ws")
7272
websocket: {
7373
only: true,
7474
initially: true,
75-
subprotocol: "quux/1.0",
75+
subprotocol: "quux.example.com",
7676
connect: ({ ctx, ws }) => {
7777
ctx.to = setInterval(() => {
7878
if (ws.readyState === WebSocket.OPEN)

0 commit comments

Comments
 (0)