@@ -65,7 +65,7 @@ export default class MqttBrokerServer implements ProtocolServer {
6565 private port = - 1 ;
6666 private address ?: string = undefined ;
6767
68- private brokerURI : string ;
68+ private brokerURI ? : string ;
6969
7070 private readonly things : Map < string , ExposedThing > = new Map ( ) ;
7171
@@ -77,15 +77,14 @@ export default class MqttBrokerServer implements ProtocolServer {
7777 private hostedBroker ?: net . Server ;
7878
7979 constructor ( config : MqttBrokerServerConfig ) {
80- this . config = config ?? this . defaults ;
81- this . config . uri = this . config . uri ?? this . defaults . uri ;
82-
8380 // if there is a MQTT protocol indicator missing, add this
84- if ( config . uri . indexOf ( "://" ) === - 1 ) {
81+ if ( config . uri ? .indexOf ( "://" ) === - 1 ) {
8582 config . uri = this . scheme + "://" + config . uri ;
8683 }
8784
8885 this . brokerURI = config . uri ;
86+ this . config = config ?? this . defaults ;
87+ this . config . uri = this . config . uri ?? this . defaults . uri ;
8988 }
9089
9190 public async expose ( thing : ExposedThing ) : Promise < void > {
@@ -446,6 +445,12 @@ export default class MqttBrokerServer implements ProtocolServer {
446445
447446 private async startBroker ( ) {
448447 return new Promise < void > ( ( resolve , reject ) => {
448+ console . log ( "here mf" ) ;
449+
450+ if ( this . brokerURI == null ) {
451+ throw new Error ( "Unexpected configuration state broker was started even if brokerURI is null" ) ;
452+ }
453+
449454 this . hostedServer = Server ( { } ) ;
450455 let server : tls . Server | net . Server ;
451456 if ( this . config . key ) {
0 commit comments