简体   繁体   中英

Smack GCM connection reset

We use the smack library to set up an XMPP connection to GCM. I have already a lot of connection on the application and we've implement ConnectionListener class of Smack Library. 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. Due to a rule set by our service provider, our socket connections are closed after 10 minutes. But shut down method of the service provider results in an error.

Then smack calls connectionListener::connectionClosedOnError method and trying to reconnect to GCM. But it's so expensive when services on heavy load.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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