我正在使用Zuul反向代理将请求发送到两个不同的后端服务。我不需要此应用程序的任何负载平衡。我仅配置了一个过滤器,该过滤器不参与此过程,并确认未调用。使用服务器中的以下代码在运行时动态填充每个服务的Zuul listOfServers
:
clientFactory.getClientConfig(SERVICE_ID).set(CommonClientConfigKey.ListOfServers, "https://" + host + ":" + port);`
相关的application.yaml设置如下:
zuul:
ignored-services: '*'
add-proxy-headers: false
sensitive-headers:
# Use more descriptive name for the Zuul servlet bypass
servlet-path: '/large-file-uploads'
ribbon:
eager-load:
enabled: true
routes:
serviceone:
path: /service_one/**
serviceId: 'service_one'
servicetwo:
path: /service_two/**
serviceId: 'service_two'
ribbon:
eureka:
enabled: false
应设置listOfServers
(通过上面的代码)后,对服务的第一个请求返回状态500,服务器打印出Zuul转发错误(可以找到{{3 }})。任何后续呼叫均按预期进行。同样,它似乎仅在后端服务重启后才发生,尽管这不是服务的问题(通过Postman测试确认)。
任何帮助将不胜感激。谢谢!
答案 0 :(得分:0)
原来是读取超时问题,请参见ryanjbaxter的答案:https://github.com/spring-cloud/spring-cloud-netflix/issues/3021