简体   繁体   English

亚马逊sqs抛出异常连接重置

[英]Amazon sqs throwing exception connection reset

I am using AmazonSQSAsyncClient to connect with Amazon SQS, but sometimes I see the following execution in the logs: 我使用AmazonSQSAsyncClient连接Amazon SQS,但有时我在日志中看到以下执行:

INFO  [AmazonHttpClient:444] Unable to execute HTTP request: Connection reset
java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:168)
    at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:293)
    at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:331)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:798)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:755)
    at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75)
    at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:166)
    at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:90)
    at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:281)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:92)
    at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:62)
    at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:254)
    at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:289)
    at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:252)
    at org.apache.http.impl.conn.ManagedClientConnectionImpl.receiveResponseHeader(ManagedClientConnectionImpl.java:191)
    at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:300)
    at com.amazonaws.http.protocol.SdkHttpRequestExecutor.doReceiveResponse(SdkHttpRequestExecutor.java:66)
    at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:127)
    at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:712)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:517)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:380)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:229)
    at com.amazonaws.services.sqs.AmazonSQSClient.invoke(AmazonSQSClient.java:2169)
    at com.amazonaws.services.sqs.AmazonSQSClient.getQueueUrl(AmazonSQSClient.java:468)
    at com.amazonaws.services.sqs.AmazonSQSClient.getQueueUrl(AmazonSQSClient.java:1476)

I am using the AmazonSQSAsyncClient through out the application as singleton. 我正在使用AmazonSQSAsyncClient作为单例的应用程序。

Code snippet is below. 代码段如下。

static{
        if(sqsObj == null){
        sqsObj = new AmazonSQSAsyncClient(new ClasspathPropertiesFileCredentialsProvider("app.properties"));
        sqsObj.setRegion(Region.getRegion(Regions.valueOf("sample region"));
    }
}

By using sqsobj, I am doing operations like create queue, send message and receive messages. 通过使用sqsobj,我正在执行诸如创建队列,发送消息和接收消息之类的操作。 It works fine but some time throws the exception as above. 它工作正常,但有时会抛出异常,如上所述。 After restarting the application it works fine for sometime. 重新启动应用程序后,它可以正常工作。

I am using aws-java-sdk-1.7.1. 我正在使用aws-java-sdk-1.7.1。 Please suggest on this. 请对此提出建议。

The "connection reset" means that the other party (ie the server) closed the connection. “连接重置”意味着另一方(即服务器)关闭了连接。

Internally the SDK builds and reuses a http connection to not have to open a connection every time you make a request. 在内部,SDK构建并重用http连接,以便在每次发出请求时都不必打开连接。

The log message tells you that the connection was reset, but normally this is not something to worry about. 日志消息告诉您连接已重置,但通常不需要担心。 The SDK will retry automatically in cases like this. SDK会在这种情况下自动重试。 So if you are only seeing this sporadically in the logs but everything works as expected you should probably not worry about it 因此,如果您只是偶尔在日志中看到这些,但一切都按预期工作,您可能不应该担心它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM