无法将我的客户端应用程序连接到 ejabberd 本地服务器

时间:2021-05-25 09:17:48

标签: android-studio xmpp ejabberd

我在 XMPP Smack 库的 android studio 中创建了一个应用程序,并在我的本地机器上运行 ejabberd 服务器。 Ejabberd 管理页面正在我的浏览器上打开。但是,我无法从我的应用程序连接到服务器

        public String USERNAME = "admin";
        public String PASSWORD = "rooban";

        public String DOMAIN = "192.168.43.74";
        public int PORT = 5222;
        @Override
        protected String doInBackground(String... strings) {

            XMPPTCPConnection mConnection;
            XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration.builder();
            config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
            config.setUsernameAndPassword(USERNAME + "@" + "localhost", PASSWORD);
            config.setHost("localhost");
            config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
            config.setPort(PORT);
            config.setDebuggerEnabled(true);
            try {
                config.setXmppDomain("localhost");
            }
            catch (XmppStringprepException e) {
                e.printStackTrace();
            }

            mConnection = new XMPPTCPConnection(config.build());
            mConnection.setPacketReplyTimeout(10000);
            Log.i("mConnection",mConnection.toString());
            try {
                Log.i("mConnecr23tion", String.valueOf(mConnection.isConnected()));
                mConnection.connect();
                Log.i("mConnection ss", String.valueOf(mConnection.isConnected()));
                mConnection.login();
                Log.i("mConnection", String.valueOf(mConnection.isConnected()));
            } catch (SmackException | IOException | XMPPException | InterruptedException e) {
                Log.d("AsyncTask", e.toString());
            }

0 个答案:

没有答案