轮询时 AWS SWF 决策程序 'java.net.SocketTimeoutException: Read timed out'
AWS SWF Decider 'java.net.SocketTimeoutException: Read timed out' when polling
每当我的 SWF Worker 应用程序进行轮询时,我都会遇到此错误。如果 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[=11=](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
)
当 HTTP 客户端套接字超时小于 61 秒时发生。长轮询不会 return 长达 60 秒并且
java.net.SocketTimeoutException: 抛出读取超时。
使用ClientConfiguration.setSocketTimeout to change the timeout. This structure is passed to AmazonSimpleWorkflowClient constructor. Looking at AmazonSimpleWorkflowClient implementation 如果未设置,它应该默认为 90 秒。因此请确保您使用的是最新的客户端并且超时设置正确。
每当我的 SWF Worker 应用程序进行轮询时,我都会遇到此错误。如果 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[=11=](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
)
当 HTTP 客户端套接字超时小于 61 秒时发生。长轮询不会 return 长达 60 秒并且 java.net.SocketTimeoutException: 抛出读取超时。
使用ClientConfiguration.setSocketTimeout to change the timeout. This structure is passed to AmazonSimpleWorkflowClient constructor. Looking at AmazonSimpleWorkflowClient implementation 如果未设置,它应该默认为 90 秒。因此请确保您使用的是最新的客户端并且超时设置正确。