Getting ConnectionTimeoutException with the host did not accept the connection within timeout

旧街凉风 提交于 2019-12-12 08:22:34

问题


Can Some one Help me, how we can solve the following problem.

nested
exception is org.apache.commons.httpclient.ConnectTimeoutException: The host did
not accept the connection within timeout of 10000 ms
        at
org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.convertHttpInvokerAccessException(HttpInvokerClientInterceptor.java:211)
        at
org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:144)
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy19.isEmployeeToken(Unknown Source)
        at
com.clickandbuy.webapps.surfer.commons.ContextUtils.isEmployeeToken(ContextUtils.java:375)
        at
com.clickandbuy.webapps.surfer.commons.ContextUtils.validateLogin(ContextUtils.java:248)
        at sun.reflect.GeneratedMethodAccessor1364.invoke(Unknown Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:329)
        at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:274)
        at org.jboss.el.parser.AstMethodSuffix.getValue(AstMethodSuffix.java:59)
        at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
        at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
        at
org.springframework.binding.expression.el.BindingValueExpression.getValue(BindingValueExpression.java:54)
        at
org.springframework.binding.expression.el.ELExpression.getValue(ELExpression.java:54)
        at
org.springframework.webflow.action.EvaluateAction.doExecute(EvaluateAction.java:77)
        at
org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188)
        at
org.springframework.webflow.execution.AnnotatedAction.execute(AnnotatedAction.java:145)
        at
org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51)
        at
org.springframework.webflow.engine.ActionState.doEnter(ActionState.java:101)
        at org.springframework.webflow.engine.State.enter(State.java:194)
        at org.springframework.webflow.engine.Flow.start(Flow.java:535)
        at
org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:364)
        at
org.springframework.webflow.engine.impl.FlowExecutionImpl.start(FlowExecutionImpl.java:222)
        at
org.springframework.webflow.executor.FlowExecutorImpl.launchExecution(FlowExecutorImpl.java:140)
        at
org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:193)
        at
org.springframework.webflow.mvc.servlet.FlowController.handleRequest(FlowController.java:174)
        at
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
        at
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
        at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
        at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        at
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
com.clickandbuy.webapps.surfer.commons.filter.LogUserIPFilter.doFilter(LogUserIPFilter.java:61)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
com.clickandbuy.webapps.surfer.commons.filter.AddHeaderFilter.doFilter(AddHeaderFilter.java:54)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
com.clickandbuy.webapps.commons.filter.SessionSizeFilter.doFilter(SessionSizeFilter.java:76)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:568)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.apache.commons.httpclient.ConnectTimeoutException: The host did
not accept the connection within timeout of 10000 ms
        at
org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:155)
        at
org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:125)
        at
org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
        at
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
        at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
        at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
        at
org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor.executePostMethod(CommonsHttpInvokerRequestExecutor.java:195)
        at
org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor.doExecuteRequest(CommonsHttpInvokerRequestExecutor.java:129)
        at
org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.executeRequest(AbstractHttpInvokerRequestExecutor.java:136)
        at
org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:191)
        at
org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:173)
        at
org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:141)
        ... 57 more
Caused by: java.net.SocketTimeoutException: connect timed out
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:519)
        at sun.reflect.GeneratedMethodAccessor284.invoke(Unknown Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:140)
        ... 70 more

My confiugration is as follows....

<bean id="loginManagerHttpInvoker" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
        <property name="serviceUrl" value="service url" />
        <property name="serviceInterface" value="service interface" />
        <property name="httpInvokerRequestExecutor">
            <bean class="org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor">
                <property name="httpClient">
                    <bean class="org.apache.commons.httpclient.HttpClient">
                        <property name="httpConnectionManager">
                            <bean class="org.apache.commons.httpclient.MultiThreadedHttpConnectionManager">
                                <property name="params">
                                    <bean class="org.apache.commons.httpclient.params.HttpConnectionManagerParams">
                                        <property name="connectionTimeout"><value>10000</value></property>
                                        <property name="defaultMaxConnectionsPerHost"><value>150</value></property>
                                        <property name="maxTotalConnections"><value>150</value></property>
                                        <property name="staleCheckingEnabled" value="true" />
                                        <property name="linger" value="-1" />
                                        <property name="soTimeout"><value>60000</value></property>
                                    </bean>
                                </property>
                            </bean>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>
    </bean>

After the server restart everything is working fine. And I could able to connect to server. What could be the problem, It happend only one time, I have never seen this before... Same configuration nothing changed....

Thanks In Advance

Sanjana


回答1:


Your program will get a ConnectionTimeoutException whenever the server side does not "exist". A timeout of 10 seconds (10000 ms) is sufficient to work in most cases to connect between any processes even when located far apart (high latency).

There are many reasons why the client cannot get a connection:

  • The server process is not running.
  • The server process is not accepting connections.
  • The address or port that the client process used to connect is not correct.
  • Route to the server is not valid

Typically, though these result in quick failure responses because the server operating system or some router is able to respond with a failure. Here are some more that may apply directly to your situation:

  • Server physically off
  • Server or server process hung
  • Server physically disconnected from the network
  • Invalid destination address and the address does not exist on the network
  • Firewall rules blocking the outgoing route from the client
  • Firewall rules blocking the incoming route to the server

These kinds of problems usually result in the time out exception because there is no return message (the client operating system just has to give up and that is the reasons for having a timeout).

This list may not be complete but may help you in troubleshooting your problem. If you can provide additional information about your configuration and network and what you specifically would like help resolving, someone here should be able to give you more specific assistance.



来源:https://stackoverflow.com/questions/2586307/getting-connectiontimeoutexception-with-the-host-did-not-accept-the-connection-w

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!