createDeferredConnectPromise() {
    let res;
    let rej;

    this.connectPromise = new Promise((resolve, reject) => {
      res = resolve;
      rej = reject;
    });

    this.connectPromise.resolve = res;
    this.connectPromise.reject = rej;
  }
Create a deferred promise that resolves as soon as the connection is established.