android中的XMPP连接错误
Posted
技术标签:
【中文标题】android中的XMPP连接错误【英文标题】:XMPP connection error in android 【发布时间】:2016-05-30 10:55:23 【问题描述】:我正在尝试使用带有开放式服务器的 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!
对此的任何帮助将不胜感激
【问题讨论】:
嗯,错误日志明确指出服务器在5秒内无法响应,请检查服务器是否因某种原因下线。鉴于您提供的描述,很难找出实际问题。 @Egor-error 日志已更改。我收到此错误internal-server-error You can read more about the meaning of this stream error at http://xmpp.org/rfcs/rfc6120.html#streams-error-conditions
@Egor-如何解决这个错误。我不明白这个错误。当我打开这个网址时。
@Egor-请告诉我如何解决这个错误
【参考方案1】:
您需要将 jre 更新到版本 8
如果您使用的是基于 Linux 的系统,请尝试使用 oracle jre 8 for openfire
【讨论】:
以上是关于android中的XMPP连接错误的主要内容,如果未能解决你的问题,请参考以下文章