Configuration adjustment for GRPC service

Ľ
  • 25 Jan '24
Hello, everybody,
I am implementing a GRPC service which has methods, i.e. request/reply 
and one streaming method, through which the server sends events at 
random intervals.
The GRPC server is written in Go, the client in C#, we are using Grpc.Core.

If the server is not running and I call one of the request/reply 
methods, an error occurs as I expect. But if I call the streaming 
method, Nginx accepts the connection and the client gets stuck on 
calling await events.ResponseStream.MoveNext(...);

I would like to ask how to configure Nginx so that an error occurs even 
if the streaming method is called if the server is not running, e.g. it 
restarts out of my control if the server on which my service is running 
restarts.

Thank you
J
  • 25 Jan '24
Have you tried configuring grpc timeouts on NGINX?

This combined with an upstream healthcheck should prevent any client
connections that aren't possible for NGINX to service.

https://nginx.org/en/docs/http/ngx_http_grpc_module.html#grpc_connect_timeout

https://docs.nginx.com/nginx/admin-guide/load-balancer/grpc-health-check/

Regards,

Jason

On Thu, Jan 25, 2024, 6:01 AM Ľuboš Pinteš <lubos.pintes at seznam.cz> wrote:

> Hello, everybody,
> I am implementing a GRPC service which has methods, i.e. request/reply
> and one streaming method, through which the server sends events at
> random intervals.
> The GRPC server is written in Go, the client in C#, we are using Grpc.Core.
>
> If the server is not running and I call one of the request/reply
> methods, an error occurs as I expect. But if I call the streaming
> method, Nginx accepts the connection and the client gets stuck on
> calling await events.ResponseStream.MoveNext(...);
>
> I would like to ask how to configure Nginx so that an error occurs even
> if the streaming method is called if the server is not running, e.g. it
> restarts out of my control if the server on which my service is running
> restarts.
>
> Thank you
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> https://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20240125/ead00c3b/attachment.htm>
Ľ
  • 25 Jan '24
Hello Jason and thank for your reply.

I am fairly new to this stuff.

Concerning health checks, does it matter if I have only one simple 
server? So no load balancing etc.?

Dňa 25. 1. 2024 o 14:01 Jason Anderson via nginx napísal(a):
> Have you tried configuring grpc timeouts on NGINX?
>
> This combined with an upstream healthcheck should prevent any client 
> connections that aren't possible for NGINX to service.
>
> https://nginx.org/en/docs/http/ngx_http_grpc_module.html#grpc_connect_timeout
>
> https://docs.nginx.com/nginx/admin-guide/load-balancer/grpc-health-check/
>
>
> Regards,
>
> Jason
>
> On Thu, Jan 25, 2024, 6:01 AM Ľuboš Pinteš <lubos.pintes at seznam.cz> wrote:
>
>     Hello, everybody,
>     I am implementing a GRPC service which has methods, i.e.
>     request/reply
>     and one streaming method, through which the server sends events at
>     random intervals.
>     The GRPC server is written in Go, the client in C#, we are using
>     Grpc.Core.
>
>     If the server is not running and I call one of the request/reply
>     methods, an error occurs as I expect. But if I call the streaming
>     method, Nginx accepts the connection and the client gets stuck on
>     calling await events.ResponseStream.MoveNext(...);
>
>     I would like to ask how to configure Nginx so that an error occurs
>     even
>     if the streaming method is called if the server is not running,
>     e.g. it
>     restarts out of my control if the server on which my service is
>     running
>     restarts.
>
>     Thank you
>     _______________________________________________
>     nginx mailing list
>     nginx at nginx.org
>     https://mailman.nginx.org/mailman/listinfo/nginx
>
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> https://mailman.nginx.org/mailman/listinfo/nginx
J
  • 28 Jan '24
Hello,

On Thu, 25 Jan 2024 14:53:51 +0100
Ľuboš Pinteš <lubos.pintes at seznam.cz> wrote:

> Hello Jason and thank for your reply.
> 
> I am fairly new to this stuff.
> 
> Concerning health checks, does it matter if I have only one simple 
> server? So no load balancing etc.?
> 

Just so you know, active health checks (on the docs.nginx.com admin
guide page) are only in NGINX Plus (commerical version of nginx).

If you're using OSS nginx you won't have active health checks 
(the 'health_check' directive).

> 
> Dňa 25. 1. 2024 o 14:01 Jason Anderson via nginx napísal(a):
> > Have you tried configuring grpc timeouts on NGINX?
> >
> > This combined with an upstream healthcheck should prevent any client 
> > connections that aren't possible for NGINX to service.
> >
> > https://nginx.org/en/docs/http/ngx_http_grpc_module.html#grpc_connect_timeout
> >
> > https://docs.nginx.com/nginx/admin-guide/load-balancer/grpc-health-check/
> >
> >
> > Regards,
> >
> > Jason
> >
> > On Thu, Jan 25, 2024, 6:01 AM Ľuboš Pinteš <lubos.pintes at seznam.cz> wrote:
> >
> >     Hello, everybody,
> >     I am implementing a GRPC service which has methods, i.e.
> >     request/reply
> >     and one streaming method, through which the server sends events at
> >     random intervals.
> >     The GRPC server is written in Go, the client in C#, we are using
> >     Grpc.Core.
> >
> >     If the server is not running and I call one of the request/reply
> >     methods, an error occurs as I expect. But if I call the streaming
> >     method, Nginx accepts the connection and the client gets stuck on
> >     calling await events.ResponseStream.MoveNext(...);
> >
> >     I would like to ask how to configure Nginx so that an error occurs
> >     even
> >     if the streaming method is called if the server is not running,
> >     e.g. it
> >     restarts out of my control if the server on which my service is
> >     running
> >     restarts.
> >
> >     Thank you