每当我的SWF工作程序应用程序轮询时,我都会遇到此错误。如果SWF队列中有条目,则会正确处理。但如果它为空,则返回此超时异常。
com.amazonaws.http.AmazonHttpClient : Unable to execute HTTP request: Read timed out
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.8.0_31]
at java.net.SocketInputStream.read(SocketInputStream.java:150) ~[na:1.8.0_31]
at java.net.SocketInputStream.read(SocketInputStream.java:121) ~[na:1.8.0_31]
at sun.security.ssl.InputRecord.readFully(InputRecord.java:465) ~[na:1.8.0_31]
at sun.security.ssl.InputRecord.read(InputRecord.java:503) ~[na:1.8.0_31]
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:961) ~[na:1.8.0_31]
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:918) ~[na:1.8.0_31]
at sun.security.ssl.AppInputStream.read(AppInputStream.java:105) ~[na:1.8.0_31]
at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:139) ~[httpcore-4.4.4.jar!/:4.4.4]
at 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]
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140) ~[httpclient-4.5.1.jar!/:4.5.1]
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57) ~[httpclient-4.5.1.jar!/:4.5.1]
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:261) ~[httpcore-4.4.4.jar!/:4.4.4]
at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:165) ~[httpcore-4.4.4.jar!/:4.4.4]
at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:167) ~[httpclient-4.5.1.jar!/:4.5.1]
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:272) ~[httpcore-4.4.4.jar!/:4.4.4]
at com.amazonaws.http.protocol.SdkHttpRequestExecutor.doReceiveResponse(SdkHttpRequestExecutor.java:82) ~[aws-java-sdk-core-1.11.22.jar!/:na]
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:124) ~[httpcore-4.4.4.jar!/:4.4.4]
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:271) ~[httpclient-4.5.1.jar!/:4.5.1]
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184) ~[httpclient-4.5.1.jar!/:4.5.1]
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184) ~[httpclient-4.5.1.jar!/:4.5.1]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82) ~[httpclient-4.5.1.jar!/:4.5.1]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55) ~[httpclient-4.5.1.jar!/:4.5.1]
at com.amazonaws.http.apache.client.impl.SdkHttpClient.execute(SdkHttpClient.java:72) ~[aws-java-sdk-core-1.11.22.jar!/:na]
at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:880) [aws-java-sdk-core-1.11.22.jar!/:na]
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:723) [aws-java-sdk-core-1.11.22.jar!/:na]
at com.amazonaws.http.AmazonHttpClient.doExecute(AmazonHttpClient.java:475) [aws-java-sdk-core-1.11.22.jar!/:na]
at com.amazonaws.http.AmazonHttpClient.executeWithTimer(AmazonHttpClient.java:437) [aws-java-sdk-core-1.11.22.jar!/:na]
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:386) [aws-java-sdk-core-1.11.22.jar!/:na]
at com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflowClient.doInvoke(AmazonSimpleWorkflowClient.java:3133) [aws-java-sdk-simpleworkflow-1.11.22.jar!/:na]
at com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflowClient.invoke(AmazonSimpleWorkflowClient.java:3103) [aws-java-sdk-simpleworkflow-1.11.22.jar!/:na]
at com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflowClient.pollForDecisionTask(AmazonSimpleWorkflowClient.java:1967) [aws-java-sdk-simpleworkflow-1.11.22.jar!/:na]
at com.amazonaws.services.simpleworkflow.flow.worker.DecisionTaskPoller.poll(DecisionTaskPoller.java:171) [aws-java-sdk-swf-libraries-1.11.22.jar!/:na]
at com.amazonaws.services.simpleworkflow.flow.worker.DecisionTaskPoller.access$0(DecisionTaskPoller.java:158) [aws-java-sdk-swf-libraries-1.11.22.jar!/:na]
at com.amazonaws.services.simpleworkflow.flow.worker.DecisionTaskPoller$DecisionTaskIterator.<init>(DecisionTaskPoller.java:44) [aws-java-sdk-swf-libraries-1.11.22.jar!/:na]
at com.amazonaws.services.simpleworkflow.flow.worker.DecisionTaskPoller.pollAndProcessSingleTask(DecisionTaskPoller.java:197) [aws-java-sdk-swf-libraries-1.11.22.jar!/:na]
at com.amazonaws.services.simpleworkflow.flow.worker.GenericWorker$PollServiceTask.run(GenericWorker.java:94) [aws-java-sdk-swf-libraries-1.11.22.jar!/:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_31]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_31]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_31]
造成这种情况的原因是什么?
我正在使用此设置:
@Workflow
@WorkflowRegistrationOptions(
defaultExecutionStartToCloseTimeoutSeconds = 259200, //3 days
defaultTaskStartToCloseTimeoutSeconds = 180
)
答案 0 :(得分:1)
当HTTP客户端套接字超时小于61秒时,会发生这种情况。长轮询不会返回最多60秒 java.net.SocketTimeoutException:抛出读取超时。
使用ClientConfiguration.setSocketTimeout更改超时。此结构将传递给AmazonSimpleWorkflowClient构造函数。查看AmazonSimpleWorkflowClient implementation如果未设置,则默认为90秒。因此,请确保您使用的是最新的客户端,并且正确设置了超时。