我在使用Mule 3.7在HTTP请求连接器上设置连接超时(不要与响应超时混淆)时遇到问题。 我正在使用的配置并没有改变启动连接和抛出之间任意约5秒的延迟" java.net.ConnectException:连接超时",即使https://docs.mulesoft.com/mule-user-guide/v/3.7/tcp-transport-reference建议设置connectionTimeout属性应该诀窍。
我错过了什么?有没有其他方法来指定此超时?或者这取决于操作系统?
流程说明问题:
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:tcp="http://www.mulesoft.org/schema/mule/tcp" xmlns:tls="http://www.mulesoft.org/schema/mule/tls" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd
http://www.mulesoft.org/schema/mule/tls http://www.mulesoft.org/schema/mule/tls/current/mule-tls.xsd
http://www.mulesoft.org/schema/mule/tcp http://www.mulesoft.org/schema/mule/tcp/current/mule-tcp.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<http:request-config name="HTTP_Request_Configuration" host="123.123.123.123" port="4444" doc:name="HTTP Request Configuration" responseTimeout="30000" usePersistentConnections="false" >
<tcp:client-socket-properties connectionTimeout="30000" timeout="30000"/>
</http:request-config>
<flow name="connectionTimeoutTestFlow">
<quartz:inbound-endpoint jobName="Knock" repeatInterval="60000" responseTimeout="100000" doc:name="Quartz">
<quartz:event-generator-job/>
</quartz:inbound-endpoint>
<logger message="Start Request" level="INFO" doc:name="Logger"/>
<http:request config-ref="HTTP_Request_Configuration" path="/debug/index.jsp" method="GET" doc:name="HTTP"/>
</flow>
</mule>
输出:
INFO 2016-02-10 12:53:55,736 [[connectionTimeoutTest].connectionTimeoutTestFlow.stage1.02] org.mule.api.processor.LoggerMessageProcessor: Start Request
ERROR 2016-02-10 12:54:01,321 [[connectionTimeoutTest].connectionTimeoutTestFlow.stage1.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Error sending HTTP request. Message payload is of type: NullPayload
Type : org.mule.api.MessagingException
Code : MULE_ERROR--2
Payload : {NullPayload}
JavaDoc : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html
********************************************************************************
Exception stack is:
1. Connect timeout (java.net.ConnectException)
org.glassfish.grizzly.connectionpool.SingleEndpointPool$ConnectCompletionHandler:1283 (null)
2. java.net.ConnectException: Connect timeout (java.util.concurrent.ExecutionException)
org.glassfish.grizzly.impl.SafeFutureImpl$Sync:349 (null)
3. java.util.concurrent.ExecutionException: java.net.ConnectException: Connect timeout (java.io.IOException)
org.mule.module.http.internal.request.grizzly.GrizzlyHttpClient:234 (null)
4. Error sending HTTP request. Message payload is of type: NullPayload (org.mule.api.MessagingException)
org.mule.module.http.internal.request.DefaultHttpRequester:287 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
********************************************************************************
Root Exception stack trace:
java.net.ConnectException: Connect timeout
at org.glassfish.grizzly.connectionpool.SingleEndpointPool$ConnectCompletionHandler.cancelled(SingleEndpointPool.java:1283)
at org.glassfish.grizzly.impl.SafeFutureImpl.notifyCompletionHandlers(SafeFutureImpl.java:185)
at org.glassfish.grizzly.impl.SafeFutureImpl.done(SafeFutureImpl.java:277)
at org.glassfish.grizzly.impl.SafeFutureImpl$Sync.innerCancel(SafeFutureImpl.java:389)
at org.glassfish.grizzly.impl.SafeFutureImpl.cancel(SafeFutureImpl.java:247)
at org.glassfish.grizzly.connectionpool.SingleEndpointPool$ConnectTimeoutWorker.doWork(SingleEndpointPool.java:1351)
at org.glassfish.grizzly.connectionpool.SingleEndpointPool$ConnectTimeoutWorker.doWork(SingleEndpointPool.java:1343)
at org.glassfish.grizzly.utils.DelayedExecutor$DelayedRunnable.run(DelayedExecutor.java:158)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:744)
********************************************************************************
答案 0 :(得分:0)
您可以使用在.xml顶部定义的全局配置,您可以在其中为所有服务指定超时,例如:
<configuration defaultTransactionTimeout="300000" defaultResponseTimeout="300000" doc:name="Configuration">
<default-threading-profile poolExhaustedAction="RUN"/>
</configuration>
我希望这会有所帮助。
答案 1 :(得分:0)
尝试增加http全局配置中的http超时,您可以执行以下操作:
<https:connector
name="HTTP_HTTPS"
cookieSpec="netscape"
validateConnections="false"
sendBufferSize="0"
receiveBufferSize="0"
receiveBacklog="0"
clientSoTimeout="1000"
serverSoTimeout="1000"
socketSoLinger="1000"
doc:name="HTTP-HTTPS"
socketMaxWait="1000"
connectionTimeout="1000"
keepAlive="true">