如何使用.yml

时间:2019-07-31 04:14:08

标签: spring microservices spring-cloud netflix-zuul

我有没有eureka服务发现的zuul网关服务器。

我使用如下所示的yml文件连接微服务和zuul。

当我执行URL超时异常时发生

ava.net.SocketTimeoutException:在java.net.SocketInputStream.socketRead0(本机方法)〜[na:1.8.0_91]处读取超时,在java.net.SocketInputStream.socketRead(SocketInputStream.java:116)〜[na :1.8.0_91]在java.net.SocketInputStream.read(SocketInputStream.java:170)〜[na:1.8.0_91]在java.net.SocketInputStream.read(SocketInputStream.java:141)〜[na:1.8.0_91 ]在org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:139)〜[httpcore-4.4.4.jar:4.4.4]在org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer (SessionInputBufferImpl.java:155)〜[httpcore-4.4.4.jar:4.4.4] at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:284)〜[httpcore-4.4.4。 jar:4.4.4]位于org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140)〜[httpclient-4.5.2.jar:4.5.2]位于org.apache.http.impl。 conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57)〜[httpclient-4.5.2.jar:4.5.2]在org.apache .http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:261)〜[httpcore-4.4.4.jar:4.4.4]位于org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:165)约org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:167)的[httpcore-4.4.4.jar:4.4.4]〜[httpclient-4.5.2.jar:4.5.2] org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:124上的org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:272)〜[httpcore-4.4.4.jar:4.4.4] )〜[httpcore-4.4.4.jar:4.4.4],位于org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:271)〜[httpclient-4.5.2.jar:4.5.2]在org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)〜[httpclient-4.5.2.jar:4.5.2]在org.apache.http.impl.execchain.RetryExec.execute( RetryExec.java:88)〜[httpclient-4.5.2.jar:4.5.2] at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)〜[http org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)处的client-4.5.2.jar:4.5.2]〜org处的[httpclient-4.5.2.jar:4.5.2]。 apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:117)〜[httpclient-4.5.2.jar:4.5.2] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java :55)〜[httpclient-4.5.2.jar:4.5.2]在org.springframework.cloud.netflix.zuul.filters.route.SimpleHostRoutingFilter.forwardRequest(SimpleHostRoutingFilter.java:324)〜[spring-cloud-netflix-核心1.1.0.RELEASE.jar:1.1.0.RELEASE],位于org.springframework.cloud.netflix.zuul.filters.route.SimpleHostRoutingFilter.forward(SimpleHostRoutingFilter.java:287)〜[spring-cloud-netflix-core -1.1.0.RELEASE.jar:1.1.0.RELEASE],位于org.springframework.cloud.netflix.zuul.filters.route.SimpleHostRoutingFilter.run(SimpleHostRoutingFilter.java:173)〜[spring-cloud-netflix-core- 1.1.0.RELEASE.jar:1.1.0.RELEASE],位于com.netflix.zuul.ZuulFilter.runFilter(ZuulFilter.java:112)〜[zuul com.netflix.zuul.FilterProcessor.processZuulFilter(-Process-1.1.0.jar:1.1.0]的com.netflix.zuul.FilterProcessor.processZuulFilter(FilterProcessor.java:197)〜com.netflix的[zuul-core-1.1.0.jar:1.1.0] .zuul.FilterProcessor.runFilters(FilterProcessor.java:161)〜[zuul-core-1.1.0.jar:1.1.0] at com.netflix.zuul.FilterProcessor.route(FilterProcessor.java:120)〜[zuul- com.netflix.zuul.ZuulRunner.route(ZuulRunner.java:96)的[core-1.1.0.jar:1.1.0]〜com.netflix的[zuul-core-1.1.0.jar:1.1.0]。 zuul.http.ZuulServlet.route(ZuulServlet.java:116)〜[zuul-core-1.1.0.jar:1.1.0] at com.netflix.zuul.http.ZuulServlet.service(ZuulServlet.java:81)〜 org.springframework.web.servlet.mvc.ServletWrappingController.handleRequestInternal(ServletWrappingController.java:158)上的[zuul-core-1.1.0.jar:1.1.0] [spring-webmvc-4.2.6.RELEASE.jar:4.2 .6.RELEASE]位于org.springframework.cloud.netflix.zuul.web.ZuulController.handleRequestInternal(ZuulController.java:43)[spring-cloud-netflix-core-1.1.0.RELEASE.jar:1.1.0.RELEASE ]在org.springframework.web.servlet.mvc.AbstractControlle r.handleRequest(AbstractController.java:147)[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]在org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:50) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:961)上的[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE] [spring-webmvc-4.2.6.RELEASE.jar :在org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895)处的[4.2.6.RELEASE] [在org.springframework处的spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]。 web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]位于org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java: 869)[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]在javax.servlet.http.HttpServlet.service(HttpServlet.java:648)[tomcat-embed-core-8.0.33.jar :8.0.33],网址为org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843 )[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE]在javax.servlet.http.HttpServlet.service(HttpServlet.java:729)[tomcat-embed-core-8.0.33.jar: 8.0.33],位于org.apache.catalina.core.ApplicationFilterChain的org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)[tomcat-embed-core-8.0.33.jar:8.0.33] .doFilter(ApplicationFilterChain.java:207)[tomcat-embed-core-8.0.33.jar:8.0.33],位于org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)[tomcat-在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)处的embed-websocket-8.0.33.jar:8.0.33] [tomcat-embed-core-8.0.33.jar:8.0.33]在org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration $ ApplicationContextHeaderFilter的org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)[tomcat-embed-core-8.0.33.jar:8.0.33] .doFilterInternal(EndpointWebMvcAutoConfiguration.java:261)[spring-boot-actuat或在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)上的1.3.5.RELEASE.jar:[3.5.RELEASE] [spring-web-4.2.6.RELEASE.jar:4.2。 6.RELEASE]位于org.apache.catalina.core.ApplicationFilterChain的org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)[tomcat-embed-core-8.0.33.jar:8.0.33] .doFilter(ApplicationFilterChain.java:207)[tomcat-embed-core-8.0.33.jar:8.0.33] at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:115)[spring-在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)的boot-actuator-1.3.5.RELEASE.jar:1.3.5.RELEASE] [spring-web-4.2.6.RELEASE.jar: 4.2.6.RELEASE]位于org.apache.catalina.core上的org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)[tomcat-embed-core-8.0.33.jar:8.0.33] .ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)[tomcat-embed- org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)处的core-8.0.33.jar:8.0.33] [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]位于org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]位于org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:240)[tomcat-embed-core-8.0.33.jar:8.0.33]在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)[tomcat-embed-core- org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87)的8.0.33.jar:8.0.33] [org-spring-4.2.6.RELEASE.jar:4.2.6.RELEASE] .springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]位于org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain .java:240)[tomcat-embed-core-8.0。 33.jar:8.0.33]在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)[tomcat-embed-core-8.0.33.jar:8.0.33]在org.springframework.web .filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]位于org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107 ),位于org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)的[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] [tomcat-embed-core-8.0.33。 jar:8.0.33]位于org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)[tomcat-embed-core-8.0.33.jar:8.0.33]位于org.springframework.web.filter .CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)[ spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)[tomcat-embed-core-8.0.33.jar:8.0.33]在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain .java:207)[tomcat-embed-core-8.0.33.jar:8.0.33]在org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:103)[spring-boot-actuator- 1.3.5.RELEASE.jar:1.3.5.RELEASE]位于org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)[spring-web-4.2.6.RELEASE.jar:4.2.6。 RELEASE]位于org.apache.catalina.core.ApplicationFilterChain.doFilter上的org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)[tomcat-embed-core-8.0.33.jar:8.0.33] (ApplicationFilterChain.java:207)[tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)[tomcat-embed-core- 8.0.33.jar:8.0.33],位于org.apache.catalina.core.Standa rdContextValve.invoke(StandardContextValve.java:106)[tomcat-embed-core-8.0.33.jar:8.0.33]在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)[tomcat嵌入-org-apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)处的-core-8.0.33.jar:8.0.33] [tomcat-embed-core-8.0.33.jar:8.0.33] org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)[tomcat-embed-core-8.0.33.jar:8.0.33] java:88)[tomcat-embed-core-8.0.33.jar:8.0.33]在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)[tomcat-embed-core-8.0.33 .jar:8.0.33],位于org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)[tomcat-embed-core-8.0.33.jar:8.0.33],位于org.apache.coyote。 org.apache.tomcat.util.net.NioEn上的AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:672)[tomcat-embed-core-8.0.33.jar:8.0.33] dpoint $ SocketProcessor.doRun(NioEndpoint.java:1502)[tomcat-embed-core-8.0.33.jar:8.0.33]位于org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.run(NioEndpoint.java: 1458)[tomcat-embed-core-8.0.33.jar:8.0.33]在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[na:1.8.0_91]在java.util.concurrent。 ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)[na:1.8.0_91],位于org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)[tomcat-embed-core-8.0 .33.jar:8.0.33],位于java.lang.Thread.run(Thread.java:745)[na:1.8.0_91]

   server:
   port: 9090

   eureka:
   client:
   enabled: false

zuul:
    #Service will be mapped under the /api URI
    prefix: /clo-services/rest
    stripPrefix: false
    #Uncomment to disable auto-registering all services read from Eureka
    #ignoredServices: '*'
     routes:
     proposals:
     path: /**/proposals/**
     url: http://localhost:6004
     stripPrefix: false
   common:
     path: /**/common/**
     url: http://localhost:8090
     stripPrefix: false
   host:
     connect-timeout-millis: 5000
     socket-timeout-millis: 10000

      hystrix:
        command:
          default:
   execution:
       isolation:
      thread:
        timeoutInMilliseconds: 6000


    spring:
        application:
             name: zuul-server

1 个答案:

答案 0 :(得分:0)

尝试

    zuul:
      host:
        connect-timeout-millis: 20000
        socket-timeout-millis: 60000