Closed lvl-mattwells closed 1 year ago
Sorry taken a while to check notifications, this seems reasonable 🙂
Actually, I don't believe this is what we want - the ws handshake is performed over HTTP so what you're seeing in Opine is that initial handshake request and the protocol is as expected.
Once the connection is established and the connection upgrade executed then the ws protocol is used, but by this point we're no longer in the remit of Opine's request middleware, instead performing event handling on the connections themselves.
It would be incorrect to indicate that the initial handshake is using a ws protocol when it isn't.
The opening handshake is intended to be compatible with HTTP-based server-side software and intermediaries, so that a single port can be used by both HTTP clients talking to that server and WebSocket clients talking to that server. To this end, the WebSocket client's handshake is an HTTP Upgrade request
Issue
Setup:
Details
Hello!
If I make a request using the browser's built-in WebSocket constructor like:
new WebSocket("ws://localhost:5555/ws")
I getreq.protocol = http
andreq.proto = ""
. What I would expect is that I would getreq.protocol = ws
, andreq.protocol = wss
for secure connections.For repro you could probably add a
console.log(req.protocol)
to your WebSockets example.Any workarounds/suggestions would be appreciated! Thanks!