Connection closed with error after a while in android

After connect a while ,the application cause this error ——“Connection closed with error”

this is my connection configuration

XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
configBuilder.setServiceName(XMPPConfig.SERVICENAME);
configBuilder.setHost(XMPPConfig.HOST);
configBuilder.setPort(XMPPConfig.PORT);
configBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
connection = new XMPPTCPConnection(configBuilder.build());
connection.setPacketReplyTimeout(XMPPConfig.TIMEOUT);

and this is the error:

java.net.SocketException: Connection reset by peer
            at org.apache.harmony.luni.platform.OSNetworkSystem.read(Native Method)
            at dalvik.system.BlockGuard$WrappedNetworkSystem.read(BlockGuard.java:273)
            at org.apache.harmony.luni.net.PlainSocketImpl.read(PlainSocketImpl.java:461)
            at org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:85)
            at java.io.InputStreamReader.read(InputStreamReader.java:255)
            at java.io.BufferedReader.read(BufferedReader.java:311)
            at org.kxml2.io.KXmlParser.peek(KXmlParser.java:925)
            at org.kxml2.io.KXmlParser.peekType(KXmlParser.java:589)
            at org.kxml2.io.KXmlParser.nextImpl(KXmlParser.java:333)
            at org.kxml2.io.KXmlParser.next(KXmlParser.java:1378)
            at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1151)
            at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPConnection.java:937)
            at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:952)
            at java.lang.Thread.run(Thread.java:1027)

May be in openfire settings/client connection:

Idle Connections Policy

1)Do not disconnect clients that are idle

N sec

You set point 2?

Need more info from openfire settings

and which libs and version smack you used

yes,you are right.I setted connection at point 2.

Even i have set it is (" N sec").

But what is the connection between this option 2 and “java.net.SocketException: Connection reset by peer” Error