我正在尝试使用带有开放式服务器的smack 4.1.4进行xmpp,其中我可以连接到服务器一段时间。然后过了一段时间我得到错误。这是我的java类。
public void init(String userId,String pwd ) {
Log.i("XMPP", "Initializing!");
this.userName = userId;
this.passWord = pwd;
XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
configBuilder.setUsernameAndPassword(userName, passWord);
configBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
configBuilder.setServiceName(DOMAIN);
configBuilder.setHost(HOST);
configBuilder.setPort(PORT);
//configBuilder.setDebuggerEnabled(true);
connection = new XMPPTCPConnection(configBuilder.build());
connection.addConnectionListener(connectionListener);
}
// Disconnect Function
public void disconnectConnection(){
new Thread(new Runnable() {
@Override
public void run() {
connection.disconnect();
}
}).start();
}
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;
} catch (IOException e) {
} catch (SmackException e) {
} catch (XMPPException e) {
}
return null;
}
};
connectionThread.execute();
}
public void login() {
try {
connection.login(userName, passWord);
//Log.i("LOGIN", "Yey! We're connected to the Xmpp server!");
} catch (XMPPException | SmackException | IOException e) {
e.printStackTrace();
} catch (Exception e) {
}
}
以下是我得到的错误
05-30 17:07:13.675 892-1180/com.demoapp.messenger W/AbstractXMPPConnection: org.jivesoftware.smack.XMPPException$StreamErrorException: internal-server-error You can read more about the meaning of this stream error at http://xmpp.org/rfcs/rfc6120.html#streams-error-conditions
05-30 17:07:13.675 892-1180/com.demoapp.messenger W/AbstractXMPPConnection: <stream:error><internal-server-error xmlns='urn:ietf:params:xml:ns:xmpp-streams'/></stream:error>
05-30 17:07:13.675 892-1180/com.demoapp.messenger W/AbstractXMPPConnection: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1003)
05-30 17:07:13.675 892-1180/com.demoapp.messenger W/AbstractXMPPConnection: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:944)
05-30 17:07:13.675 892-1180/com.demoapp.messenger W/AbstractXMPPConnection: at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:959)
05-30 17:07:13.675 892-1180/com.demoapp.messenger W/AbstractXMPPConnection: at java.lang.Thread.run(Thread.java:856)
05-30 17:07:13.675 892-1180/com.demoapp.messenger D/xmpp: ConnectionClosedOn Error!
对此有任何帮助将不胜感激
答案 0 :(得分:1)