moscajs / mosca

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

Catch http exception on server start #733

Closed martin-doyle closed 6 years ago

martin-doyle commented 6 years ago

Unfortunately, #731 only caught the MQTT server errors. For the HTTP server there is an additional change necessary. A unit test is provided.

martin-doyle commented 6 years ago

Sure. I will be out for a week. So, it might take some time.Am 25.03.2018 1:06 vorm. schrieb Matteo Collina notifications@github.com:@mcollina commented on this pull request.

In test/server_error.js:

  • it('should get MQTT port Error: listen EADDRINUSE', function (done) {
  • this.timeout(10000); // have to wait for the inject with delay of two seconds
  • instance = new mosca.Server(moscaSettings(), function (err, server) {
  • expect(server === instance).to.be.true;
  • });
  • secondInstance = new mosca.Server(moscaSettings(), function (err, server) {
  • expect(server === secondInstance).to.be.true;
  • });
  • secondInstance.on('error', function (err) {
  • expect(err.toString().substr(0, 24)).to.be.equal('Error: listen EADDRINUSE');
  • done();
  • });
  • });
  • it('should get HTTP port Error: listen EADDRINUSE', function (done) {
  • this.timeout(10000); // have to wait for the inject with delay of two seconds
  • instance = new mosca.Server(moscaSettings(), function (err, server) {

can you please add an assertion that checks that err is null or undefined? Also in all other cases.

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

martin-doyle commented 6 years ago

CI tests failed but for other reasons.