4ib3r / StompBrokerJS

NodeJS StompBroker
MIT License
35 stars 66 forks source link

Cannot use with noServer: true #29

Open kneczaj opened 3 years ago

kneczaj commented 3 years ago

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.

k7moorthi commented 3 years ago

+1

@kneczaj Thanks for the workaround!