nginx配置nacosgrpc连接

报错信息
java.util.concurrent.TimeoutException: Waited 3000 milliseconds (plus 501200 nanoseconds delay) for com.alibaba.nacos.shaded.io.grpc.stub.ClientCallsKaTeX parse error: Expected ‘}’, got ‘EOF’ at end of input: ….ProtoLiteUtilsMessageMarshaller@5981f4a6, responseMarshaller=com.alibaba.nacos.shaded.io.grpc.protobuf.lite.ProtoLiteUtils

M

e

s

s

a

g

e

M

a

r

s

h

a

l

l

e

r

@

63

d

f

a

d

a

0

,

s

c

h

e

m

a

D

e

s

c

r

i

p

t

o

r

=

c

o

m

.

a

l

i

b

a

b

a

.

n

a

c

o

s

.

a

p

i

.

g

r

p

c

.

a

u

t

o

.

R

e

q

u

e

s

t

G

r

p

c

MessageMarshaller@63dfada0, schemaDescriptor=com.alibaba.nacos.api.grpc.auto.RequestGrpc

MessageMarshaller@63dfada0,schemaDescriptor=com.alibaba.nacos.api.grpc.auto.RequestGrpcRequestMethodDescriptorSupplier@6f231ced}}}}}]]
at com.alibaba.nacos.shaded.com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:508) ~[nacosclient-2.0.4.jar:na]
java.util.concurrent.ExecutionException: com.alibaba.nacos.shaded.io.grpc.StatusRuntimeException: UNAVAILABLE: io exception
at com.alibaba.nacos.shaded.com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:566) ~[nacosclient-2.0.4.jar:na]
at com.alibaba.nacos.shaded.com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:445) ~[nacosclient-2.0.4.jar:na]

解决方案

1、暴露 nacos 集群端口偏移1000

例如:nacos默认端口8848,需要把9848(8848+1000)也暴露出来

注意:如果是docker集群部署需要7848 端口也一起暴露出来。(7848 端口用于节点选举来确定集群领袖 Leader

在这里插入图片描述

2、修改 nginx.conf文件

http {
	# 负载均衡配置
	upstream lb-nocos{
		server 127.0.0.1:8845 weight=1;
		server 127.0.0.1:8847 weight=1;
		server 127.0.0.1:8849 weight=1;
	}
	# nacos服务配置
	server {
        listen       8848;
        server_name  localhost;
		location / {
			# 反向代理
			proxy_pass http://lb-nocos;
        }
	}
}

# nacos的grpc协议配置
stream {
       # 负载均衡配置(TCP长连接配置)
       upstream lb-nocos-tcp{
         server 127.0.0.1:9845 weight=1;
         server 127.0.0.1:9847 weight=1;
         server 127.0.0.1:9849 weight=1;
       }

        server {
          listen 9848;
          proxy_pass lb-nocos-tcp;
        }
}

集群部署参考https://blog.csdn.net/weixin_51311218/article/details/122617027

原文地址:https://blog.csdn.net/weixin_51311218/article/details/123623470

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_32212.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注