powered by Jive Software

Can't Login To Openfire from Smack

Hi, Few Weeks back i was able to login to my openfire server and now im not able to connect with my same java code
the Error im facing is…

W/System.err( 1009): org.jivesoftware.smack.SmackException$ConnectionException: The following addresses failed
W/System.err( 1009): at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectUsingConfiguration(XMPPTCPConnection.java:668)
W/System.err( 1009): at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection.java:971)
W/System.err( 1009): at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.java:435)
W/System.err( 1009): at com.grevity.oyindori.MyXMPP$2.doInBackground(MyXMPP.java:79)
W/System.err( 1009): at com.grevity.oyindori.MyXMPP$2.doInBackground(MyXMPP.java:75)
W/System.err( 1009): at android.os.AsyncTask$3.call(AsyncTask.java:378)
W/System.err( 1009): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
W/System.err( 1009): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
W/System.err( 1009): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err( 1009): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/System.err( 1009): at java.lang.Thread.run(Thread.java:919)

and my java code is

    private static final String DOMAIN = "team-grevity.in";
    private static final String HOST = "team-grevity.in";
    private static final int PORT = 5222;
    private String userName = "";
    private String passWord = "";
    org.jivesoftware.smack.chat.ChatManager chatManager;
    AbstractXMPPConnection connection;
    XMPPConnectionListener connectionListener = new XMPPConnectionListener();
    private boolean connected;
    private boolean isToasted;
    private boolean chat_created;
    private boolean loggedin;
    Chat chat;
    public void init(String userId, String pwd, EventChannel.EventSink eventSink) throws XmppStringprepException {
        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.setHost(HOST);
        configBuilder.setXmppDomain(DOMAIN);
        configBuilder.setPort(PORT);
        connection = new XMPPTCPConnection(configBuilder.build());
        connection.addConnectionListener(connectionListener);
        chatManager = ChatManager.getInstanceFor(connection);
        chatManager.addChatListener(
                new ChatManagerListener() {
                    @Override
                    public void chatCreated(Chat chat, boolean createdLocally) {
                        chat.addMessageListener(
                                new ChatMessageListener() {
                                    @Override
                                    public void processMessage(Chat chat, Message message) {
                                        System.out.println(chat.getParticipant() + ":" + message.getBody());
                                        Log.e("Message Received : ",message.getBody());
                                        eventSink.success(message);
                                        Log.e("Message ID : ",message.getStanzaId());
                                    }
                                }
                        );
                    }
                }
        );
    }

    public void connect() {
        AsyncTask<Void, Void, Boolean> connectionThread = new AsyncTask<Void, Void, Boolean>() {
            @Override
            protected Boolean doInBackground(Void... arg0) {
                try {
                    connection.connect();
//                    login();
                    connected = true;
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (SmackException e) {
                    e.printStackTrace();
                } catch (XMPPException e) {
                    e.printStackTrace();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                return null;
            }
        };
        connectionThread.execute();
    }

and the strange this is im still able to connect to my openfire server from Spark Windows Client

OK its resolved the problem was at my dns …actually i reseted my dns records and things gets messed up

1 Like

This topic was automatically closed 62 days after the last reply. New replies are no longer allowed.