Skip to content

Commit 668fbee

Browse files
committed
Add sane defaults to channel keepalive to avoid ECONNRESET bug
1 parent 39b876f commit 668fbee

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/connection/grpc.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ export const grpcClient = (config: GrpcConnectionParams): GrpcClient => {
120120
const channelOptions: ChannelOptions = {
121121
'grpc.max_send_message_length': MAX_GRPC_MESSAGE_LENGTH,
122122
'grpc.max_receive_message_length': MAX_GRPC_MESSAGE_LENGTH,
123+
// Send keepalive pings every 10 seconds, default is 2 hours.
124+
'grpc.keepalive_time_ms': 10 * 1000,
125+
// Keepalive ping timeout after 5 seconds, default is 20 seconds.
126+
'grpc.keepalive_timeout_ms': 5 * 1000,
127+
// Allow keepalive pings when there are no gRPC calls.
128+
'grpc.keepalive_permit_without_calls': 1,
123129
};
124130
if (config.grpcProxyUrl) {
125131
// grpc.http_proxy is not used by grpc.js under-the-hood

0 commit comments

Comments
 (0)