ws://myserver.com/path?param=1
is a valid WebSocket URI. However, the way that your WebSocket server application can access the path and query string will differ depending on what WebSocket server framework you are using.
If you are using the Node.js einaros/ws
library, then in your websocket connection object will have the full path with the query string at upgradeReq.url
.
For example this:
wss.on('connection', function(ws) {
console.log("url: ", ws.upgradeReq.url);
};
will print url: /path?param=1
when you connect to ws://myserver.com/path?param=1
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…