powered by Jive Software

Cannot login to Jabber Server via Smack

Hello,

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.

Chris Blyth

chris.blyth@amsjv.com

Chris

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.

-Rajesh

hi chris,rajesh

i’'m new to this world of jabber,smack…i wanna try a very simple program of writing a client using smack to a jabber server.

if any one of u guyzz can give me code of basic example of creating a client and connecting to server using smack API.it would be great.

chris if u can post ur whole prgm i will also try to run and find the problem.

rajesh if u can post a sample code it would be gr88.

and also please let me know if there are any other sites where i can find some tutorials on this

cya

bobby

Guys,

Here is my full, yet very basic program:

import org.jivesoftware.smack.*;

public class Connector {

public static void main(String[] args) {

try {

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?

Any help greatly appreciated.

Chris Blyth

chris.blyth@amsjv.com

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.

Chris.

hi chris

thanx for posting the sample code.but when i try to run.i get an xmlpull parser exception.do i need to download anything to fix it if so which API.

r u getting any exception of this kind ???

bye

bobby

Chris

Please try the following:

1.Change the connection to use the server name instead of the IP (either DNS or Windows name)

XMPPConnection connection = new XMPPConnection(“server name”, 5222);

2.Change the catch block statement to print out the error object so that we can know the actual error being thrown

System.out.println("Failed : " + e);

Please post your progress.

-Rajesh

Hi guys,

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);

newAccount.createAccount(“userName”, “password”);

connection.login(“userName”, “password”);

This segment of code enables me to login ok.

Chris

It is MANDATORY that you need tohave avalid user name and password to log on to any jabber server.

In my previous posts I did ask you to check logon success using a client (you could have used Jive Messenger)

What you have done now is created a new logon !

-Rajesh