简体   繁体   English

GCM连接重置

[英]Smack GCM connection reset

We use the smack library to set up an XMPP connection to GCM. 我们使用smack库来建立与GCM的XMPP连接。 I have already a lot of connection on the application and we've implement ConnectionListener class of Smack Library. 我已经在应用程序上建立了很多连接,并且已经实现了Smack库的ConnectionListener类。 So we use following method. 因此,我们使用以下方法。

@Override
public void connectionClosedOnError(Exception e) {
    logger.error(e, "connectionListener::connectionClosedOnError::appKey::{}::clientId::{}", appKey, clientId);
}

This implementation has been working for a long time. 该实现已经工作了很长时间。 But last 2 days we got an error like this; 但是最近两天,我们收到了这样的错误;

05:16:50,846 ERROR [CcsClient   ] - 
connectionListener::connectionClosedOnError
::appKey::xxx::clientId::xxxx
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:196)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:442)
at sun.security.ssl.InputRecord.read(InputRecord.java:480)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:934)
at sun.security.ssl.SSLSocketImpl.
readDataRecord(SSLSocketImpl.java:891)
at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:154)
at java.io.BufferedReader.read1(BufferedReader.java:205)
at java.io.BufferedReader.read(BufferedReader.java:279)
at org.xmlpull.mxp1.MXParser.fillBuf(MXParser.java:2992)
at org.xmlpull.mxp1.MXParser.more(MXParser.java:3046)
at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1144)
at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)
at org.jivesoftware.smack.PacketReader.
parsePackets(PacketReader.java:312)
at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:48)
at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:76)

What is the reason of this ? 这是什么原因呢?

I found the source of the problem. 我找到了问题的根源。 We are opening a lot of socket connection to GCM to send out notification. 我们正在打开许多与GCM的套接字​​连接,以发出通知。 Due to a rule set by our service provider, our socket connections are closed after 10 minutes. 根据我们的服务提供商设置的规则,我们的套接字连接将在10分钟后关闭。 But shut down method of the service provider results in an error. 但是服务提供商的关闭方法会导致错误。

Then smack calls connectionListener::connectionClosedOnError method and trying to reconnect to GCM. 然后,smack调用connectionListener :: connectionClosedOnError方法并尝试重新连接到GCM。 But it's so expensive when services on heavy load. 但是当服务负载很重时,它是如此昂贵。

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

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