/** * Connect subscription socket */ subConnect() { if (this.subClient) return; this.subClient = new SubscriptionClient( process.env.WS_SERVER + constants.graphqlBase, { reconnect: true, connectionParams: async () => { if (this.refreshingPromise) await this.refreshingPromise; return { token: await this.getAccessToken() }; } } ); this.subClient.maxConnectTimeGenerator.duration = () => this.subClient.maxConnectTimeGenerator.max; this.subClient.onConnected(this.onSubConnected.bind(this)); this.subClient.onReconnected(this.onSubReconnected.bind(this)); this.subClient.onDisconnected(this.onSubDisconnected.bind(this)); this.subClient.onError(this.onSubError.bind(this)); }