Closed namgk closed 7 years ago
I don't see we have any test for attachHttpServer yet, I'm creating a new one then.
added some unit tests, however, there are a few things:
if no path is specified in attachHttpServer, and a mqtt client connect to 'ws://
/ ', should the server ignore the part and still serve such client as if it was connecting to just 'ws:// '?
Keep the same behaviour as it was before, like it's now in code.
was it your intention to always put a mqtt server on port 1883 as default (the case of empty option provided to mosca server)? This doesn't make much sense in the case where you are attaching to an existing http server.
I know it is possible to have server with all interface.
My point is that when I'm attaching to an existing http server, I don't want the port 1883 to be occupied, that's the reason why I'm using mqtt-over-ws.
You can just specify the interfaces you want to listen to, or none.
the problem is if I specify none, there will still be a mqtt server listens on port 1883.
oh do you mean I should do
var mqttServer = mosca.Server({interface:[]})
? What I'm using now is
var mqttServer = mosca.Server({})
And this occupies my 1883 port.
Yes, 'interfaces'
, not 'interface'
.
The following test failed, it's throwing Error: no interface defined
it.only("should not occupy 1883 port while attached to http server", function(done) {
server = http.createServer();
mqttServ = new mosca.Server({interfaces:[]});
mqttServ.attachHttpServer(server);
});
Would you mind sending a fix?
sure, I just want to make sure your intention in that case. I'll send another commit.
fixed empty interfaces options, refactored the tests to reflect this.
hi Matteo, do you have a plan to merge? Thanks
I'm traveling till the end of this week, I will have a look afterwards.
Hi Matteo, that code block was under the assumption that there should be minimum one interface in the option. However this doesn't hold anymore due to the case where you are attaching the mqtt stack on an existing http server.
I deleted that code block.
perfect, I'll try to assemble a release asap.
Fixes this #605