Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xmpp smack 4.1.1中启用流管理的正确方法是什么_Xmpp_Smack_Stream Management - Fatal编程技术网

Xmpp smack 4.1.1中启用流管理的正确方法是什么

Xmpp smack 4.1.1中启用流管理的正确方法是什么,xmpp,smack,stream-management,Xmpp,Smack,Stream Management,我一直在搜索用于在smack中启用流管理的方法,但没有任何东西对我有效 此函数isSmAvailable()始终返回false,我使用prosody作为XMPP服务器,其中安装并启用了SMACK[mod_smacks],下面是我的代码 XMPPTCPConnectionConfiguration.Builder configureBuilder = XMPPTCPConnectionConfiguration.builder(); configureBuilder.setServiceName(

我一直在搜索用于在smack中启用流管理的方法,但没有任何东西对我有效

此函数isSmAvailable()始终返回false,我使用prosody作为XMPP服务器,其中安装并启用了SMACK[mod_smacks],下面是我的代码

XMPPTCPConnectionConfiguration.Builder configureBuilder = XMPPTCPConnectionConfiguration.builder();
configureBuilder.setServiceName(Config.XMPP_HOST);
configureBuilder.setHost(HOST);
//configureBuilder.allowEmptyOrNullUsernames();
configureBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);


    //configureBuilder.setDebuggerEnabled(true);
    SmackConfiguration.DEBUG = true;
    xmppConnection = new XMPPTCPConnection(configureBuilder.build());
    Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.accept_all);




    XMPPTCPConnection.setUseStreamManagementResumptiodDefault(true);
    //PingManager
    xmppConnection.setUseStreamManagement(true);
    xmppConnection.setUseStreamManagementResumption(true);

    ReconnectionManager reconnectionManager = ReconnectionManager.getInstanceFor(xmppConnection);
    reconnectionManager.enableAutomaticReconnection();


    try {
      MyLog.w("Connecting to xmpp server");
       xmppConnection.setPacketReplyTimeout(100000);
       xmppConnection.connect();
       //xmppConnection.sendSmAcknowledgement();


       if (xmppConnection.isSmEnabled()) {
      MyLog.w("stream M is enabled");
       } else {
      MyLog.w("stream M is not enabled");
       }


       if (xmppConnection.isSmAvailable()) {
      MyLog.w("stream M available");
       } else {
      MyLog.w("stream M is not available");
       }

       //xmppConnection.
       xmppConnection.addConnectionListener(new ConnectionListener() {
       @Override
       public void connected(XMPPConnection xmppConnection) {
       //logger.warning("Connected to server successfully");
       MyLog.w("Connected to server");
       }

       @Override
       public void authenticated(XMPPConnection xmppConnect, boolean b) {
       //logger.warning("Nice it is authenticated too");
       MyLog.w("Finally logged into the server");

       }

       @Override
       public void connectionClosed() {
       //logger.warning("Connected to server failed");
       }

       @Override
       public void connectionClosedOnError(Exception e) {
       //logger.warning(e.getMessage());
       MyLog.w("Connection close on error" + e.getMessage());
       }

       @Override
       public void reconnectionSuccessful() {
       //I think here we need to relogin the user
       MyLog.w("Reconnected successfully ....thanks to RC");
       }

       @Override
       public void reconnectingIn(int i) {

      }

       @Override
       public void reconnectionFailed(Exception e) {
      MyLog.w("Reconnection Failed " + e.getMessage());
       }
      });
    } catch (Exception e) {
      MyLog.w("connected-error" + e.getMessage());
    }
我尝试使用添加streamFeature进行流管理

xmppConnection.addStreamFeature()但它告诉我该函数是私有的

addStreamFeature(元素、命名空间、提供程序)也不起作用

你能帮我弄清楚这件事吗?还是我做错了什么


谢谢

这段代码在服务器端为我工作--


检查您的ejabbered配置文件是否启用流管理

stream_management: true
resend_on_timeout: true
resume_timeout: 300
在android代码中,您只需添加到下一行,即可在应用程序中启用流管理

 static{
    XMPPTCPConnection.setUseStreamManagementDefault(true);
    XMPPTCPConnection.setUseStreamManagementResumptionDefault(true);
}
可能重复的
 static{
    XMPPTCPConnection.setUseStreamManagementDefault(true);
    XMPPTCPConnection.setUseStreamManagementResumptionDefault(true);
}