Skip to main content

getting @IP:port from a peerID

12 replies [Last post]
nissayjxta
Offline
Joined: 2008-04-10

Hi,

I'm newbie in jxta im asking for how to get an IP address : port from a peerID, because i need it to detect a node failure

Please help me im blocked !!!!!!!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
g_gupta
Offline
Joined: 2008-04-07

hi adamman71,
can u pl'z give your ID so that i can clear my doubts more clearly,,, i w'll be very thankful to u...

adamman71
Offline
Joined: 2007-01-31

What ID?

adamman71
Offline
Joined: 2007-01-31

I would search for the peer endpoint address in route advertisements...

nissayjxta
Offline
Joined: 2008-04-10

i didnt understand your ansewer ??? what do you mean by that ??

adamman71
Offline
Joined: 2007-01-31

JXTA defines different types of advertisements. Route advertisements are one of these. They contain two interesting attributes: for the Peer ID and for the endpoint address. May be you can try to search for route advertisements locally (like you would for a peer or a peer group) by specifying the ID of the peer you are looking for. Then, you could use the getDestEndpointAddresses() from the route advertisement to extract the list of accessible addresses to the peer. If you are using JXSE, one of these should be an IP address.

Cheers,

J.

nissayjxta
Offline
Joined: 2008-04-10

Maybe i have not well explained my problem, so my problem is:

i have to detect nodes failure, so i want to extract from each nodes (by their Peer IDs) the IP address and Port then it will be easy to detect the deconnection by using sockets.

If is not possible to extract the Ip address:port from the Peer ID, How can I detect the deconnection of a peer.

So please help me i am really blocked, it should exist a solution

adamman71
Offline
Joined: 2007-01-31

Hi,

Getting a peer IP address is not always going to solve your problem, especially if your peer is located behind a NAT. In that case, its real IP address will be unknown, because the NAT will have translated it. If you try to ping that address, you will most probably ping the NAT, but not the peer itself, which is not want you want...

Moreover, if the peer you are trying to reach is only accessible via a RELAY peer, any IP address you may obtain will be completely useless, because JXTA will be using the HTTP protocol. Your peer will still be active, but IP addresses won't help you to find out.

The method you are trying to use is OK if you know that the peer you are probing has a fixed IP address. But most of the time, you don't know that beforehand and I believe you would like a solution for every peer.

The good news is that JXTA needs to solve that connection problem too. If I got it well, you should try to obtain a Messenger for the Endpoint Address of your peer using the Endpoint Service getMessenger() method. Then you can check its status with the USABLE static field. Check the Javadoc.

That should solve your issue.

Cheers,

J.

nissayjxta
Offline
Joined: 2008-04-10

Hi,
So First of all i wanna to thank you for your ansewers they are very useful, so i tried what u said, extract a messenger then apply the USABLE static attribut from Messenger class.but it gives nothing, so i tried to apply the isClosed method, but it did not change even if the peer is disconnected (the remote peer that i want to detect its deconnection), so here is my code :

PeerAdvertisement advmstr=(PeerAdvertisement)conferenceObj.getConferenceParticipants().get(0);

String pID=advmstr.getPeerID().toString();

EndpointAddress endpointAddress =new EndpointAddress(pID);
EndpointService myEndpointService = conferenceGroup.getEndpointService();

Messenger ms = myEndpointService.getMessenger(endpointAddress);

boolean biC = ms.isClosed();

System.out.println("isClosed : "+biC);// it gives always false

So that code is in the participant side (Client) and the participant want to detect the master (server) deconnection, so i extract the ID of the master then its EndpointAddress then the Service, and the messenger at the end, then i checked if the status is closed, so when the master is connected it gives "false" that's nice, the problem is when the master colapse it gives always "false" and it does not change to false.

So Im waiting for your ansewer

adamman71
Offline
Joined: 2007-01-31

Hi,

OK. You should not create the endpoint address yourself. When you connect with a remote peer, JXTA will automatically create (or retrieve from other peers) a RouteAdvertisement to that remote peer.

This advertisement will be stored locally on your peer, so you would need to fetch it with the DiscoveryService.getLocalAdvertisements() method. You should extract the endpoint addresses of this destination peer with RouteAdvertisment.getDestEndpointAddresses(). This will give you the list of addresses to try to reach the target peer.

Now, this technique will work if you have already performed a connection to that peer (otherwise, you will surely not have a RouteAdvertisement stored locally). Don't forget that advertisements have a publication life time, so they disappear from your local peer after some time if they are not republished.

Hope this helps,

J.

cksenti
Offline
Joined: 2008-01-28

"OK. You should not create the endpoint address yourself. When you connect with a remote peer, JXTA will automatically create (or retrieve from other peers) a RouteAdvertisement to that remote peer. "

Hi adamman71:
Thanks for your explanation about how to get ip:port from RouteAdvertisment

Besides, I have a question:

I had studied that each rendezvous peer has a Global Peerview which contains a list of PeerID. Is RouteAdvertisement for each Peer in the list also stored in that rendezvous peer?

I hope to make sure that while replicating SrdiMessage in RDV
( JXSE: Srdi.replicateEntries() ) whether it needs to spend another network traffic to allocate destination peer.

adamman71
Offline
Joined: 2007-01-31

That is a good question. I believe that yes in most case, but that is not really important. If a RouteAdvertisement is missing, the endpoint service of the rendezvous peer has means to find it from other peers when necessary.

J.

cksenti
Offline
Joined: 2008-01-28

Thanks for your answer