Opened 3 weeks ago

Closed 3 weeks ago

#2243 closed defect (invalid)

grpc_socket_keepalive on; Doesn't work

Reported by: f4nff@… Owned by:
Priority: minor Milestone:
Component: documentation Version: 1.19.x
Keywords: Cc:
uname -a: Linux WIKIHOST-210831V4Q1K8 5.4.0-81-generic #91-Ubuntu SMP Thu Jul 15 19:09:17 UTC 2021 x86_64 x8
64 x86_64 GNU/Linux
nginx -V: built by gcc 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
built with OpenSSL 1.1.1l 24 Aug 2021
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --with-http_stub_status_module --with-http_ssl_module --w
h-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-openssl=/root/openss
1.1.1l --with-stream

Description

    server {

		listen 443	ssl http2;
		server_name	d1h.xyz;
		access_log	/dev/null ;
		error_log	/dev/null ;


		ssl_certificate 			../tls/d1h.xyz.pem;
		ssl_certificate_key 		../tls/d1h.xyz.key;
		ssl_protocols		TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
	
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            grpc_pass grpcs://223.5.5.5:443;
			grpc_socket_keepalive	on;
			grpc_ssl_protocols TLSv1.3;
			grpc_send_timeout 60s;
			grpc_read_timeout 60s;
			grpc_next_upstream_tries 0;
			grpc_next_upstream_timeout 0;

        }

	}

After testing, turn on grpc_socket_keepalive on; the connection will also be actively disconnected.

grpcs It should be a long connection, I use tcp forwarding, there is no problem.

stream {
      server {
             listen 8443;
             proxy_pass 223.5.5.5:443;
             proxy_connect_timeout 10s;
             proxy_timeout 15s;
               }
   }

Change History (2)

comment:1 by f4nff@…, 3 weeks ago

# nginx -V
nginx version: nginx/1.21.2
built by gcc 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
built with OpenSSL 1.1.1l  24 Aug 2021
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-openssl=/root/openssl-1.1.1l --with-stream
Last edited 3 weeks ago by f4nff@… (previous) (diff)

comment:2 by Maxim Dounin, 3 weeks ago

Resolution: invalid
Status: newclosed

The grpc_socket_keepalive directive configures SO_KEEPALIVE option on the socket, which is to be used to ensure activity on the connection even if there is no application-level traffic. This ensures that the connection is still alive, and relevant states are not removed by intermediate firewalls, if any.

To configure keepalive connection cache, so the same upstream connection can be used for multiple requests, consider using the keepalive directive the upstream block.

Note: See TracTickets for help on using tickets.