gpt4 book ai didi

android - 在 android 中聊天时 Quickblox Chat 连接断开

转载 作者:行者123 更新时间:2023-11-29 19:27:19 28 4
gpt4 key购买 nike

我正在开发一个涉及 Quickblox 的安卓应用程序。我不断收到消息“聊天连接已断开”。阅读 logcat 后,这就是我得到的:

12-08 11:15:31.214 13894-14722/com.quickblox.sample W/AbstractXMPPConnection: Connection closed with error java.net.SocketTimeoutException: Read timed out at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method) at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:705) at java.io.InputStreamReader.read(InputStreamReader.java:233) at java.io.BufferedReader.read(BufferedReader.java:325) at org.jivesoftware.smack.util.ObservableReader.read(SourceFile:41) at org.kxml2.io.KXmlParser.fillBuffer(KXmlParser.java:1515) at org.kxml2.io.KXmlParser.peekType(KXmlParser.java:992) at org.kxml2.io.KXmlParser.next(KXmlParser.java:349) at org.kxml2.io.KXmlParser.next(KXmlParser.java:313) at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(SourceFile:1240) at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(SourceFile:1014) at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(SourceFile:1029) at java.lang.Thread.run(Thread.java:818) 12-08 11:15:31.216 13894-14722/com.quickblox.sample D/SMACK: XMPPConnection closed due to an exception (0) 12-08 11:15:31.216 13894-14722/com.quickblox.sample W/System.err: java.net.SocketTimeoutException: Read timed out 12-08 11:15:31.216 13894-14722/com.quickblox.sample W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method) 12-08 11:15:31.216 13894-14722/com.quickblox.sample W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl$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.sample W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(SourceFile:1240) 12-08 11:15:31.216 13894-14722/com.quickblox.sample W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(SourceFile:1014) 12-08 11:15:31.217 13894-14722/com.quickblox.sample W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(SourceFile:1029) 12-08 11:15:31.217 13894-13894/com.quickblox.sample I/VerboseQbChatConnectionListener: connectionClosedOnError(): Read timed out 12-08 11:15:31.217 13894-14722/com.quickblox.sample W/System.err: at java.lang.Thread.run(Thread.java:818)

我找不到相同的解决方案。

最佳答案

套接字是您用来通过网络进行通信的工具(例如,连接到 Internet 上的服务器)。错误信息的意思是某个程序试图通过网络从远程计算机接收数据,但是一段时间没有接收到数据,所以程序停止等待接收数据。

这里是可以通过增加套接字超时来解决此问题的代码 fragment ,因为 Quickblox 中的默认 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);

关于android - 在 android 中聊天时 Quickblox Chat 连接断开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41032852/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com