Is it possible to subscribe/publish to pubsub node in other XMPP server ?

Hello, thank you very much for various useful discussions in the forum.

My question is that is it possible to subscribe/pubilsh to pubsub node in other XMPP server ?
Here is a situation:
- Two different XMPP servers exist - xmpp1-server and xmpp2-server.
- In xmpp1-server, there is a pubsub node called topic1-node.
- user2@xmpp2-server who logins to xmpp2-server wants to subscribe/publish to topic1-node in xmpp1-server.
Is it possible to subscribe/publish cross-domain xmpp server's pubsub node ?
I confirmed that I could chat between user1 in xmpp1-server and user2 in xmpp2-server, but not succeeded to access pubsub nodes in different xmpp server.

I sent following messages to xmpp2-server:

...
<stream:stream xmlns='jabber:client' to='xmpp2-server' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' id='2808538778' xml:lang='en'>
<iq id='Dq4ny-4' type='set'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource>Smack</resource></bind></iq>
<iq id='Dq4ny-6' type='set'><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></iq>
<iq id='Dq4ny-8' type='get'><query xmlns='jabber:iq:roster'></query></iq>
<presence id='Dq4ny-9'><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.igniterealtime.org/projects/smack' ver='os2Kusj3WEOivn5n4iFr/ZEO8ls='/></presence>
<iq to='pubsub.xmpp1-server' id='Dq4ny-11' type='get'><query xmlns='http://jabber.org/protocol/disco#info' node='topic1-node'></query></iq>

However, I received following error message:

<iq from='pubsub.xmpp1-server' to='user2@xmpp2-server/Smack' type='error' xml:lang='en' id='03hP6-11'><query xmlns='http://jabber.org/protocol/disco#info' node='topic1-node'/><error code='404' type='cancel'><remote-server-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>

For sure I do not understand well about relationship between xmpp1-server and pubsub.xmpp1-server..
I'm very happy if you can give me any advices.

Yes, it is possible to

Yes, it is possible to subscribe to other servers, if they are connected through s2s. It seems you have network setup issue and the two servers are not communicating with each other.
You probably have not properly set up DNS that would allow both server to support s2s, or did not enable s2s in your config file.

Thank you for your reply !

Thank you for your reply ! Because I tested two XMPP servers in same network, I thought it's no necessary to set DNS record to our network.

I setup following SRV record to enable s2s communication (by seeing http://wiki.xmpp.org/web/SRV_Records), however, still cannot communicate..
I checked SRV record seems to be set correctly to our DNS server by using "dig" command.

_xmpp-server._tcp.xmpp1-server.mydomain.com. 86400 IN SRV 5 0 5269 xmpp1-server.mydomain.com.
_xmpp-server._tcp.xmpp2-server.mydomain.com. 86400 IN SRV 5 0 5269 xmpp2-server.mydomain.com.

I also tried following record, but still not succeeded..

_xmpp-server._tcp.xmpp1-server.mydomain.com. 86400 IN SRV 5 0 5269 pubsub.xmpp1-server.mydomain.com.
_xmpp-server._tcp.xmpp2-server.mydomain.com. 86400 IN SRV 5 0 5269 pubsub.xmpp2-server.mydomain.com.

Am I wrong with this setting ? Or my client code ?
I will continue to find solution, but your any further advices will be very helpful.
Thank you !

If you use default port and

If you use default port and the name of domain is same as name of the server, SRV records are not necessary. You can in that case rely on /etc/hosts for development / testing.

Hi, thank you. But I still

Hi, thank you. But I still cannot succeeded.
I guess my s2s setting (and /etc/hosts configuration) must be ok.
Maybe problem is my code..
I'm using smack for xmpp library, so I have to ask in their community.
But just showing my code for someone interesting to the wrong code...

//configuration to connect XMPP2-server
XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
  .setHost("xmpp2-sever.mydomain.com")
  .setPort(5222)
  .setServiceName("xmpp2-server.mydomain.com")
  .setSecurityMode(SecurityMode.disabled)
  .build();

XMPPTCPConnection con = new XMPPTCPConnection(config);
con.connect();
con.login("user2","password");

//get pubsub manager from XMPP1-server
PubSubManager manager = new PubSubManager(con,"pubsub.xmpp1-server.mydomain.com");

Thanks a lot.

I do not think it is related

I do not think it is related to the client code. Check your ejabberd log and make sure both server can get in touch and communicate with each other.

Thank you for your

Thank you for your comment.

When I run this code with user2 in xmpp2-server:

PubSubManager manager = new PubSubManager(con,"pubsub.xmpp1-server.mydomain.com");
Node node = manager.getNode("topic1-node");

Then, this sends following XMP message to xmpp1-server.

<iq to='pubsub.xmpp1-server.mydomain.com' id='CSRu4-12' type='get'><query xmlns='http://jabber.org/protocol/disco#info' node='topic1-node'></query></iq>

Then, I got following log in logs/ejabberd.log

@ejabberd_s2s:new_connection:460 New s2s connection started <0.1518.0>
@ejabberd_s2s_out:log_s2s_out:1303 Trying to open s2s connection: xmpp2-server.mydomain.com -> pubsub.xmpp1-server.mydomain.com with TLS=false
@ejabberd_s2s_out:open_socket:266 s2s connection: xmpp2-server.mydomain.com -> pubsub.xmpp1-server.mydomain.com (remote server not found)

Then, I changed my code as following (replace pubsub.xmpp1-server.mydomain.com to xmpp1-server.mydomain.com just to understand what's happening)

PubSubManager manager = new PubSubManager(con,"xmpp1-server.mydomain.com");
Node node = manager.getNode("topic1-node");

Then, this sends following XMP message to xmpp1-server.

<iq to='xmpp1-server.mydomain.com' id='CSRu4-12' type='get'><query xmlns='http://jabber.org/protocol/disco#info' node='topic1-node'></query></iq>

Then, I got another log.

@ejabberd_s2s:new_connection:460 New s2s connection started <0.1532.0>
@ejabberd_s2s_out:log_s2s_out:1303 Trying to open s2s connection: xmpp2-server.mydomain.com -> xmpp1-server.mydomain.com with TLS=false
@ejabberd_listener:accept:299 (#Port<0.4010>) Accepted connection 133.27.170.67:37315 -> 133.27.170.237:5269
@ejabberd_s2s_in:stream_established:524 Accepted s2s dialback authentication for xmpp1-server.mydomain.com (TLS=false)
@ejabberd_s2s_out:wait_for_validation:422 Connection established: xmpp2-server.mydomain.com -> xmpp1-server.mydomain.com with TLS=false

By seeing this log, I felt that s2s communication seems to be ok.
But still I have "item not found" error so I cannot get node from xmpp1-server.
I tried following node identifiers, but all of them are not succeeded.

Node node = manager.getNode("topic1-node");
Node node = manager.getNode("pubsub.xmpp1-server.mydomain.com/topic1-node");
Node node = manager.getNode("xmpp.pubsub:pubsub.xmpp1-server.mydomain.com/topic1-node");

Do you think this is still problem of s2s communication ?
Thank you very much for your kind support.

Look at the XMPP protocol

Look at the XMPP protocol level from your client and check what are the packets exchanged. In case of doubt, tries to format / send the packets manually. I personally did not try pubsub on Smack and maybe something is not compliant with the packet they send. Always try checking by going to the XMPP protocol level.

Thank you for your reply. I'm

Thank you for your reply. I'm now trying to communicate in a raw message level by connecting to XMPP server by telnet (telnet xmpp1-server 5222). That's taking me to more understanding to the XMPP communication.
However, I still do not know what stanza should be sent to discover/subscribe/publish nodes in different XMPP server.

Usually I use <iq to="pubsub.domain.com"> stanza to identify pubsub service. "pubsub.domain.com" represents a service (or special JID?), not host name. This makes me confuse - how should I identify pubsub services in another XMPP server ? I tried iq to="pubsub@domain.com", "pubsub.domain.com@domain.com" or everything I came up with. But reply from XMPP server is always "remote-server not found" or "service-unavailable".

If my understanding is correctly, what I have to do is (1) first identify XMPP server name, then (2) send iq to pubsub service on the XMPP server. But I don't know how to do this or is really possible.

I have read related XEP carefully, and also googled as much as possible, however, there are no information or examples how to access pubsub services in different XMPP server.
Just found a discussion on accessing pubsub on different XMPP server, and it seems to be impossible..
https://support.process-one.net/browse/EJAB-674

You also need to make sure

You also need to make sure that all the remote components are in DNS or /etc/hosts file. It means you need to have pubsub.domain.com resolved to the proper IP address as well.

I did, thank you !!! I did

I did, thank you !!! I did not understand well that I have to set the entry of pubsub.xmpp1-server.mydomian.com in DNS or /etc/hosts.

I added following entries into /etc/hosts :

XXX.XXX.XXX.XXX xmpp1-server.mydomain.com xmpp1-server
XXX.XXX.XXX.XXX pubsub.xmpp1-server.mydomain.com pubsub.xmpp1-server

Thank you again for your kind support.

Syndicate content