Error in connecting to GMail - Connection refused

Hello,

I tried to integrate Smack API on my web page, getting the following error:


Exception caught XMPPError connecting to talk.google.com:5222.: (502)

– caused by: java.net.ConnectException: Connection refused: connect


The source code is as follows:

import org.jivesoftware.smack.XMPPConnection;

import org.jivesoftware.smack.XMPPException;

import org.jivesoftware.smack.Chat;

public class Example3 {

public void createcon() throws XMPPException

{

XMPPConnection con = new XMPPConnection(“jabber.org”);

con.login(“username”, “password”);

 Chat chat = con.createChat("username@jivesoftware.com");

chat.sendMessage(“Hey, how’'s it going?”);

}

public static void main(String a[])

{

Example2 e = new Example2();

try

{

e.createcon();

}

catch(Exception le)

{

le.printStackTrace();

}

}

}

Can you help me where i have gone wrong, do i need to configure any other pre-requisites or settings.

we also tried using the port number 5222, 5223, 433 but throws the same error.

Would like to know what is the port number that needs to be used.

Any other suggestions are welcome.

Thanks in advance

Jhansi

Hi,

I am bale to install the “Google Talk” and login in with my username/password and able to chat.

But when i am using the same XMPP API on my web page i am not able to chat.

What is the port number that neeeds to be used. How do i know that port is been disabled in my organization.

Thanks

Jhansi

Hi Jhansi,

ask your network or firewall administrator if you want to know which ports are open. The connection refused message is very clear about that port talk.google.com:5222 is blocked, maybe ports 5222 and 5223 are both blocked.

Please avoid duplicate posts. You can easily edit your message after posting if this is necessary.

LG

Hi

Thank you, now the port is opened and my program is successfully executing but the messages are not going to other end(receiver).

I am not able to send the messages to a person on the other end eventhough the other user is online.

Thanks in Advance.

Have a look in the debugger to see if the messages are actually being received. If not post a sample of your app code .

Hi

Here I am sending my code.

import org.jivesoftware.smack.XMPPException;

import org.jivesoftware.smack.Chat;

import org.jivesoftware.smack.GoogleTalkConnection;

public class ExampleClass {

GoogleTalkConnection con = null;

ExampleClass() //throws Exception

{

try

{

con = new GoogleTalkConnection();

System.out.println(“Connection Established”);

con.login(“xxxxx”, “yyyyy”);

System.out.println(“Login”);

      Chat newChat  = con.createChat("anotheruser@gmail.com");

System.out.println(“Before sendMessage”);

      //con.login("myuser@gmail.com", "mypassword");

      //Chat newChat  = con.createChat("otheruser@gmail.com");

newChat.sendMessage(“Howdy!!”);

     System.out.println("Message Sent to anotheruser@gmail.com");

}

catch(XMPPException e)

{

System.out.println("Exception caught in XMPP Exception: "+e);

}

}

public static void main(String args[])

{

ExampleClass ex = new ExampleClass();

}

}[/code]

It is executing sucessfully but the messages are not going to other end.

And it also is not preventing the worng email id of the receiver.It is acccepting all the email ids.Could you please help me in sloving the problem.

Thanks in Advance

Jhansi