grpc-node
grpc-node copied to clipboard
@grpc/grpc-js refresh connection when using nginx proxy or k8s ingress
I would like to force the http2 session used by the @grpc/grpc-js subchannel after an amount of time. Infact many servers/proxies (like nginx) use the http2_max_requests parameter to close the http2 socket server side in a unxpected way. So I would prefer to garbage and refresh the connection before the server drops it.
Anyone has some suggestion?
There isn't a way to do this. For the client, the main signal that a connection should be discarded and recreated is when that connection gets closed by the server.
You say that nginx is closing the socket "in an unexpected way". What do you mean by that, exactly?
Nginx requires you set the parameter http2_max_requests (http://nginx.org/en/docs/http/ngx_http_v2_module.html#http2_max_requests) and after that number of http2 requests (which, more or less, correspond to an equivalent number of grpc calls) it close the socket and both the grpc streams receceive errors and needs to be restored and grpc calls get errors (generally GOAWAY errors or RST errors).
Sure we can set a big number as http2_max_requests but soon or later you meet this unexpected moment, that I would like to anticipate refreshing the http2 connection because it reaches on Nginx side that number of requests.
Hi, are there any updates on this? Or maybe a workaround to peridically close connections on server for clean up (forcing client to do dns resolution again)? I tried grpc.max_connection_age_ms but it doesn't seem to work at all. Using @grpc/[email protected]
grpc.max_connection_age_ms is supported since 1.18
Support for grpc.max_connection_age_ms in server arguments was added in @grpc/grpc-js version 1.8.