Skip to content

Websockets dont work with a router #421

Closed
@Tarang

Description

@Tarang

I'm not sure if this is a bug or not but websockets wont work with a proxy table e.g

var options = {
router: {
    'a.websterten.com': '127.0.0.1:150',
    'b.websterten.com' : '127.0.0.1:151',
}
};

var server = httpProxy.createServer(options);

It works fine proxying web requests. But websockets don't work. If I access the site directly it does work (with websockets)

I also unsuccessfully tried adding in

server.on('upgrade', function (req, socket, head) {
    server.proxy.proxyWebSocketRequest(req, socket, head);
});

It also looks like server.on('upgrade doesn't fire. In addition, even without the above event. If there are attempts to use websockets (after a while). The below error will appear:

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
    at Socket.EventEmitter.addListener (events.js:160:15)
    at Socket.Readable.on (_stream_readable.js:663:33)
    at Socket.EventEmitter.once (events.js:179:8)
    at TCP.onread (net.js:527:26)

After a while it will run out of memory and crash.

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