我正在为涉及QuickBlox的Android应用程序。我一直在收到消息"聊天连接已被删除"。阅读logcat后,这就是我得到的:
12-08 11:15:31.214 13894-14722/com.quickblox.Sample w/AbstractXmppConnection:连接与错误关闭 java.net.sockettimeoutexception:读取时机 在com.android.org.conscrypt.nativecrypto.ssl_read(本机方法) 在com.android.org.conscrypt.opensslsocketimpl $ sslinputstream.read(opensslsocketimpl.java:705) at Java.io.io.inputStreamReader.Read(inputStreamReader.java:233) 在java.io.io.bufferedreader.read(bufferedreader.java:325) atorg.jivesoftware.smack.util.observablereader.read(sourcefile:41) atorg.kxml2.io.kxmlparser.fillbuffer(kxmlparser.java:1515) atorg.kxml2.io.kxmlparser.peektype(kxmlparser.java:992) atrg.kxml2.io.kxmlparser.next(kxmlparser.java:349) atrg.kxml2.io.kxmlparser.next(kxmlparser.java:313) atorg.jivesoftware.smack.tcp.xmpptcpconnection $ packetReader.parsepackets(sourcefile:1240) atorg.jivesoftware.smack.tcp.xmpptcpconnection $ packetReader.Access $ 300(SourceFile:1014) atorg.jivesoftware.smack.tcp.xmpptcpconnection $ packetReader $ 1.run(sourcefile:1029) 在java.lang.thread.run(thread.java:818) 12-08 11:15:31.216 13894-14722/com.quickblox.sample d/smack:XMPPConnection因例外而关闭(0) 12-08 11:15:31.216 13894-14722/com.quickblox.sample w/system.err:java.net.sockettimeoutexception:阅读时间 12-08 11:15:31.216 13894-14722/com.quickblox.sample w/system.err:at com.android.org.conscrypt.nativecrypto.sssl_read(本机方法) 12-08 11:15:31.216 13894-14722/com.quickblox.sample w/system.err:at com.android.org.org.conscrypt.opensslsocketimplsocketimpl $ sslinputstream.read(opensslsocketimpl.java:705) 12-08 11:15:31.216 13894-14722/com.quickblox.sample w/system.err:at Java.io.inputStreamReader.Read(InputStreamReader.java:233) 12-08 11:15:31.216 13894-14722/com.quickblox.sample w/system.err:at Java.io.bufferedReader.Read(BufferedReader.java:325) 12-08 11:15:31.216 13894-14722/com.quickblox.sample w/system.err:at org.jivesoftware.smack.util.observablereader.read(sourcefile:41) 12-08 11:15:31.216 13894-14722/com.quickblox.sample w/system.err:at org.kxml2.io.kxmlparser.fillbuffer(kxmlparser.java:1515) 12-08 11:15:31.216 13894-14722/com.quickblox.sample w/system.err:at org.kxml2.io.kxmlparser.peektype(kxmlparser.java:992) 12-08 11:15:31.216 13894-14722/com.quickblox.sample w/system.err:at org.kxml2.io.kxmlparser.next(kxmlparser.java:349) 12-08 11:15:31.216 13894-14722/com.quickblox.sample w/system.err:at org.kxml2.io.kxmlparser.next(kxmlparser.java:313) 12-08 11:15:31.216 13894-14722/com.quickblox.quickblox.sample w/system.err:at org.jivesoftware.smack.tcp.xmpptcpcpcpcpconnection $ packetReader.parsereader.parsepackets(sourcefile:1240) 12-08 11:15:31.216 13894-14722/com.quickblox.quickblox.sample w/system.err:at rog.jivesoftware.smack.tcp.xmpptcpcpcpconnection $ packetReader.access.access.access $ 300(SourceFile:1014) 12-08 11:15:31.217 13894-14722/com.quickblox.quickblox.sample w/system.err:at org.jivesoftware.smack.tcp.xmpptcpcpconnection $ packetReader $ 1.run(sourcefile:1029) 12-08 11:15:31.217 13894-13894/com.quickblox.sample I/verboseqbchatConnectionListener:ConnectionClosedonError():阅读时间 12-08 11:15:31.217 13894-14722/com.quickblox.sample w/system.err:在java.lang.thread.run(thread.java:818)
我找不到相同的解决方案。
套接字是您通过网络通信的(例如,在Internet上连接到服务器)。错误消息意味着程序正在尝试通过网络接收来自远程计算机的数据,但是一段时间内未收到任何数据,因此该程序停止等待收到数据。
这是代码段,可以通过增加套接字超时来解决此问题,因为nicketBlox中的默认sockettimeout为30秒。
QBChatService.ConfigurationBuilder chatServiceConfigurationBuilder = new QBChatService.ConfigurationBuilder();
chatServiceConfigurationBuilder.setSocketTimeout(180); //Sets chat socket's read timeout in seconds
chatServiceConfigurationBuilder.setKeepAlive(true); //Sets connection socket's keepAlive option.
QBChatService.setConfigurationBuilder(chatServiceConfigurationBuilder);