Skip to content

Subprotocols in 4.3.2 #4244

Answered by B-R-Bender
B-R-Bender asked this question in Q&A
Jan 11, 2022 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

Alright, I've got it working, though it's not stated in the docs.
First you need to specify a transport

const socket = io("wss://localhost:3500", {
    transports: ["websocket"],
    protocols: ["custom-protocol"]
});

than on the server side you can get it with

io.on("connection", (socket) => {
  console.log(socket.client.conn.transport.socket.protocol);
});

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@darrachequesne
Comment options

Answer selected by B-R-Bender
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants