alibaba / nacos

an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
https://nacos.io
Apache License 2.0
29.48k stars 12.66k forks source link

nacos uses vip+nginx load balancing to cause a client to appear UNAVAILABLE: Network closed for unknown reason #12297

Open tanglinyan opened 1 week ago

tanglinyan commented 1 week ago

Describe the bug nacos uses vip+nginx load balancing to cause a client to appear UNAVAILABLE: Network closed for unknown reason This works when accessing specific nacos nodes, but does not work when load balancing via nginx Is nacos http service stateless, and if so, what about grpc

UNAVAILABLE: Network closed for unknown reason appears once every 3 seconds

hosts.conf 192.168.4.151 yanfa-nacos1 192.168.4.145 yanfa-nacos2 192.168.4.146 yanfa-nacos3

Desktop (please complete the following information):

Additional context

image image image
KomachiSion commented 1 week ago

It should be your nginx or vip will close the connection with an interval.

Please make sure your nginx and vip transport by tcp but not http and https. And make sure them will not reuse and redistribution connection with any dimensions.

I suggest you try to connect nacos server directly, if connect directly is ok. there must be some config problem in vip or nginx to close connection each 3 seconds.

tanglinyan commented 1 week ago

It is normal to use VIP or connect to one nacos service The above error occurs with nginx load balancing My related configuration is provided above

tanglinyan commented 1 week ago

I hope you can help me. This problem has been bothering me for a long time

KomachiSion commented 1 day ago
stream {

    upstream grpc_server {
       server 127.0.0.1:9848;
    }

    server {
        listen 9080 so_keepalive=on;
        proxy_responses 1;
        proxy_timeout 20s;
        proxy_pass grpc_server;

    }
}

I use this configuration in nginx work well. you can try it. If can't work well. I suggest you find out which configuration make the connection closed by nginx or vip by yourself.

tanglinyan commented 1 day ago

Thank you very much. I'll try it your way.