StompBrokerJS
StompBrokerJS copied to clipboard
Cannot use with noServer: true
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.
+1
@kneczaj Thanks for the workaround!