StompBrokerJS icon indicating copy to clipboard operation
StompBrokerJS copied to clipboard

Cannot use with noServer: true

Open kneczaj opened this issue 4 years ago • 1 comments

Description

StompServer has mandatory argument of HttpServer. However if multiple websocket connections are needed at one http server, the websocket server needs to be setup with noServer: true as described here: https://github.com/websockets/ws#multiple-servers-sharing-a-single-https-server

Expectation

This should be possible, so these args are passed further to ws Server constructor:

const stompServer = new StompServer({
        noServer: true
});

Workaround

There is a workaround available to pass an http server which will not be used later:

const stompServer = new StompServer({
        path: '/any-path',
        // this is a fake server passed because stomp-broker-js does not want to pass
        // { server: undefined, noServer: true } to ws library, which is supported and totally should work.
        server: http.createServer()
});

Then websocket server is available anyway at stompServer.socket, and the instruction for multiple socket connection is still able to be followed.

kneczaj avatar Dec 04 '20 10:12 kneczaj

+1

@kneczaj Thanks for the workaround!

k7moorthi avatar Dec 16 '20 16:12 k7moorthi