简体   繁体   中英

XMPP connection error in android

I am trying to do xmpp using smack 4.1.4 with open fire server in which I am able to connect to server for sometime. Then after sometime I am getting Error. Here is my java class.

    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) {
        }

    }

Following is error i am getting

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!

Any help regarding this will be appreciated

  • You need to update your jre to version 8
  • if you're using a Linux based system try to use oracle jre 8 for openfire

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM