I am attempting to login to my jabberd server via Smack. I can connect to the server via the following line of code:
XMPPConnection connection = new XMPPConnection(IPAddress, Port);
But when i try to log a user onto the server using the following line of code, it does not log the user on:
connection.login(userName, password);
i have tried registering the user via the JabberIM client prior to attempting this but it does not work, not even when i try to use an unregistered username and password.
The smack jar file is correctly imported and sitting in the classpath. the code compiles ok.
Where am i going wrong? Any help greatly appreciated.
Can you post the values of IPAddress & Port ? I presume that userName and password are initialised with the values corresponding to the ones you used to register on the the server.
What is the exception or error thrown ?
Please ensure that you are able to log on using any other Jabber client to isolate server or connectivity problems.
XMPPConnection connection = new XMPPConnection("10.1.3.189, 5222);
connection.login(“chris”,“chrispass”);
} catch (Exception e) {
System.out.err(“Failed”);
}
}
}
I can log into the server using the JabberIM client so I dont think its a server specific problem. The connection is ok. its when the Connector app tries to login as “chris” that the server does not authorise the login.
Would it be better if i did not create the profile for “chris” using JabberIM, but instead wrote my own chris.xml file? If so, what are the core tags that are needed in this file?
Also, please not the above IPAddress is protected from a firewall so cannot be connected to from the outside world, only through my company intranet. sorry. but that should not affect why it is not working for me.
I have come across a solution to my problem. In order to connect and send a message to the server, I first need to create the new Account using the AccountManager class.
AccountManager newAccount = new AccountManager(connection);