mirror of https://github.com/grpc/grpc-node.git
grpc-js: Handle errors when trying to ping
This commit is contained in:
parent
586f7c6db9
commit
31d28b5f14
|
@ -361,12 +361,21 @@ export class Subchannel {
|
||||||
this.handleDisconnect();
|
this.handleDisconnect();
|
||||||
}, this.keepaliveTimeoutMs);
|
}, this.keepaliveTimeoutMs);
|
||||||
this.keepaliveTimeoutId.unref?.();
|
this.keepaliveTimeoutId.unref?.();
|
||||||
this.session!.ping(
|
try {
|
||||||
(err: Error | null, duration: number, payload: Buffer) => {
|
this.session!.ping(
|
||||||
this.keepaliveTrace('Received ping response');
|
(err: Error | null, duration: number, payload: Buffer) => {
|
||||||
clearTimeout(this.keepaliveTimeoutId);
|
this.keepaliveTrace('Received ping response');
|
||||||
}
|
clearTimeout(this.keepaliveTimeoutId);
|
||||||
);
|
}
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
/* If we fail to send a ping, the connection is no longer functional, so
|
||||||
|
* we should discard it. */
|
||||||
|
this.transitionToState(
|
||||||
|
[ConnectivityState.READY],
|
||||||
|
ConnectivityState.TRANSIENT_FAILURE
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private startKeepalivePings() {
|
private startKeepalivePings() {
|
||||||
|
|
Loading…
Reference in New Issue