moscajs / mosca

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

Catch exception on server start #731

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', ... I added a unit test as required.