当我再次在Smack上线时,我正试图实现离线消息 这是我的连接代码我能够重新连接并继续聊天但是没有获得离线消息也曾使用OfflineManager但是它正在消息零消息......
public void connectConnection() {
AsyncTask<Void, Void, Boolean> connectionThread = new AsyncTask<Void, Void, Boolean>() {
@Override
protected Boolean doInBackground(Void... arg0) {
// Create a connection
try {
connection.connect();
login();
connected = true;
scheduleTaskExecutor = Executors.newSingleThreadScheduledExecutor();
scheduleTaskExecutor.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
Log.e("xmpp", "inside run()");
Log.d("xmpp", "isconnect: " + connection.isConnected() + " Auth: " + connection.isAuthenticated());
Log.d("xmpp", "getPacketReplyTimeout: "+String.valueOf(connection.getPacketReplyTimeout()));
SettingStore ss=new SettingStore(getApplicationContext());
if (ss.getStartChatValue()){
try {
Presence presence = new Presence(Presence.Type.available);
connection.sendPacket(presence);
} catch (SmackException.NotConnectedException e) {
e.printStackTrace();
}
if (connection.isConnected()) {
sendMessagesToServer();
} else {
try {
connection.connect();
login();
} catch (SmackException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (XMPPException e) {
e.printStackTrace();
}
}
}
else {
disconnectAndStopTimmer();
}
}
}, 0, 2, TimeUnit.SECONDS);
} catch (IOException e) {
} catch (SmackException e) {
} catch (XMPPException e) {
}
return null;
}
};
connectionThread.execute();
}
我准备连接超时错误
09-30 19:07:20.796 10323-10382/? W/AbstractXMPPConnection: Connection closed with error
javax.net.ssl.SSLException: Read error: ssl=0x60fefe48: I/O error during system call, Connection timed out
at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)
at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:690)
at java.io.InputStreamReader.read(InputStreamReader.java:233)
at java.io.BufferedReader.read(BufferedReader.java:325)
at org.kxml2.io.KXmlParser.fillBuffer(KXmlParser.java:1506)
at org.kxml2.io.KXmlParser.peekType(KXmlParser.java:986)
at org.kxml2.io.KXmlParser.next(KXmlParser.java:346)
at org.kxml2.io.KXmlParser.next(KXmlParser.java:310)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1164)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:944)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:959)
at java.lang.Thread.run(Thread.java:862)
09-30 19:07:20.796 10323-10382/? D/xmpp: ConnectionClosedOn Error!
答案 0 :(得分:0)
将您的连接移至后台服务,以便始终连接。
在openfire中,可以选择重新发送离线消息
服务器&gt;服务器设置&gt;离线消息
存储离线消息以供日后检索。邮件将在下次收件人登录时传递。
当用户连接到xmpp
时,这将自动再次发送消息