moscajs / mosca

MQTT broker as a module
mosca.io
3.2k stars 513 forks source link

Catch exception on server start #729

Closed martin-doyle closed 6 years ago

martin-doyle commented 6 years ago

In case of the use of mosca embedded in another program, an unhandled exception causes the main program to fail. Currently, this prevents node-red from being started if a port is already in use. With this change the exception can be caught with server.on('error', ...

mcollina commented 6 years ago

Can you please add a unit test?

martin-doyle commented 6 years ago

OK. I will check the existing tests and get back to you.

martin-doyle commented 6 years ago

Opps. Obviously, every change is now sent as a pull request. This is not what I wanted, sorry.