Skip to content

use 'wss' connection from page served over http #169

@ghost

Description

the following code in "lib/socket.io/transports/websocket.js" returns a location header with the 'ws' scheme if the origin is not https, regardless of whether the websocket was opened with a 'wss' scheme:

 var origin = this.request.headers.origin,
       location = (origin && origin.substr(0, 5) == 'https' ? 'wss' : 'ws')
                   + '://' + this.request.headers.host + this.request.url;

i couldn't find anything in the websocket spec that disallows using 'wss' websocket connections from pages server over http, and in chromium this results in:

Error during WebSocket handshake: location mismatch: wss://hostname:port//node.js/realtime/websocket != ws://hostname:port//node.js/realtime/websocket

if i missed something, and the spec doesn't allow this, so be it. if not, i'm happy to work up a patch that allows the websocket data to use a tunnel even if the page html doesn't. (yes, there are use cases for this, as the network the html travels over may be trusted, while the websocket data may use a different, untrusted network.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions