powered by Jive Software

Unable to send IM to users on different domains

Hello,

I’m not familiar with the XMPP protocol at all so I apologize in advance for what may be obvious. What I’m attempting to do is use SMACK to send IM notifications, primarially to gchat users, but I can only seem to send messages to people on the same domain as the one as the one used in authentication on XMPPConnection.login().

Example:

In the following example, the user someone@domain_a.com is sending a message to someone@domain_b.com and it doesn’t get received - no errors are thrown. If the recipient’s email were changed to someone_else@domain_a.com however, the message is sent/received no problem.

import org.jivesoftware.smack.Chat;
import org.jivesoftware.smack.ChatManager;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.MessageListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Message; ConnectionConfiguration config = new ConnectionConfiguration(<server>, <port>, <domain>);
XMPPConnection connection = New XMPPConnection(config); connection.connect();
connection.login(someone@domain_a.com, <password>); ChatManager chatManager = connection.getChatManager(); Chat chat = chatManager.createChat(someone@domain_b, new MessageListener() {
     public void processMessage(Chat chat, Message msg) {
          System.out.println("Received message "+ msg);
     }
}); chat.sendMessage(<msg>);

Please let me know what I’m doing wrong here…

Thanks in advance,

Message was edited by: John Everick

I made a very noob mistake: I needed to have the user that’s authenticated to have the recipient on their gchat list…

This solution works just fine.

1 Like