关于spirngcloud中的zuul访问其他服务出现Read timed out问题
1.使用zuul作为网关访问服务A,当A中存在一条比较耗时的查询时,zuul网关进入FallbackProvider的fallbackResponse接口方法中,并报java.lang.RuntimeException: java.net.SocketTimeoutException: Read timed out的异常。
2.经过资料查找,配置文件做了如下的超时配置:
zuul:
# zuul转发请求会过滤默认的请求头,例如Authorization,这里使用sensitive-headers清空默认请求头
sensitive-headers:
prefix: /platform
ignoredServices: '*'
routes:
blogService:
path: /blog/**
serviceId: platform-blog
stripPrefix: false
host:
connect-timeout-millis: 10000
socket-timeout-millis: 60000
feign:
client:
config:
default:
connectTimeout: 60000
# 请求 超时时间
readTimeout: 60000
hystrix:
enabled: false
hystrix:
command:
default:
execution:
timeout:
# 是否开启超时熔断, 如果为false, 则熔断机制只在服务不可用时开启
enabled: false
isolation:
strategy: SEMAPHORE
# 配置hystrix熔断超时,它适用策略THREAD和SEMAPHORE
thread:
timeoutInMilliseconds: 60000
作为一个springcloud的初学者,我不知道上面那些超时会生效,索性全部配置上去了
3.尝试结果还是出现上面的报错信息,我经过报错的堆栈定位到源码某个方法,里面的配置信息不知道有没有帮助,在这里还是把它贴出来
ClientConfig:GZipPayload:true, PrimeConnectionsClassName:com.netflix.niws.client.http.HttpPrimeConnection, ProxyPort:null, MinPrimeConnectionsRatio:1.0, StaleCheckingEnabled:null, FollowRedirects:false, RequestIdHeaderName:null, Port:7001, NFLoadBalancerMaxTotalPingTime:null, Version:null, DeploymentContextBasedVipAddresses:platform-blog, IsHostnameValidationRequired:null, PrimeConnectionsURI:/, listOfServers:, MaxTotalConnections:200, ConnectionCleanerRepeatInterval:30000, InitializeNFLoadBalancer:null, EnableZoneExclusivity:false, MaxConnectionsPerHost:50, TrustStorePassword:null, VipAddress:null, EnableMarkingServerDownOnReachingFailureLimit:null, MaxTotalHttpConnections:200, ProxyHost:null, EnablePrimeConnections:false, KeyStore:null, MaxTotalTimeToPrimeConnections:30000, PoolMaxThreads:200, UseIPAddrForServer:false, KeyStorePassword:null, MaxAutoRetries:0, AppName:null, ConnectionPoolCleanerTaskEnabled:true, IgnoreUserTokenInConnectionPoolForSecureClient:null, NIWSServerListFilterClassName:null, EnableConnectionPool:true, ReadTimeout:1000, PrioritizeVipAddressBasedServers:true, ConnectionManagerTimeout:2000, NFLoadBalancerPingClassName:com.netflix.loadbalancer.DummyPing, NFLoadBalancerStatsClassName:null, PoolKeepAliveTimeUnits:SECONDS, PoolKeepAliveTime:900, NFLoadBalancerClassName:com.netflix.loadbalancer.ZoneAwareLoadBalancer, RequestSpecificRetryOn:null, ServerListUpdaterClassName:null, NFLoadBalancerPingInterval:null, CustomSSLSocketFactoryClassName:null, SecurePort:null, BackoffTimeout:null, IsClientAuthRequired:false, EnableZoneAffinity:true, IsSecure:null, MaxRetriesPerServerPrimeConnection:9, PoolMinThreads:1, MaxHttpConnectionsPerHost:50, TrustStore:null, ServerDownFailureLimit:null, RulePredicateClasses:null, ClientClassName:com.netflix.niws.client.http.RestClient, TargetRegion:null, MaxAutoRetriesNextServer:1, NIWSServerListClassName:com.netflix.loadbalancer.ConfigurationBasedServerList, OkToRetryOnAllOperations:false, EnableGZIPContentEncodingFilter:false, ConnectTimeout:1000, SendBufferSize:null, NFLoadBalancerRuleClassName:com.netflix.loadbalancer.AvailabilityFilteringRule, VipAddressResolverClassName:com.netflix.client.SimpleVipAddressResolver, ConnIdleEvictTimeMilliSeconds:30000, ServerListRefreshInterval:null, ForceClientPortConfiguration:null, Linger:null, ServerDownStatWindowInMillis:null, ReceiveBufferSize:null
上面我发现ReadTimeout:1000的字眼,我不知道之前的配置文件中的配置是否生效。实在解决不了了,跪求指点一下,think you...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论