Skip to main content

remotePublish question

2 replies [Last post]
siggyuke
Offline
Joined: 2007-10-08
Points: 0

I read in the Brendon Wilson book (I know it's an old book & refers to old JXTA version - but upto chapter 4 all still relevant, ie. code matches the current version of JXTA) that a call to remotePublish publishes a peers advert to all other peers on the same Peer Group as the peer - so that, as I see it, all other peers on the network pick this up & store the advert locally.

Is this correct with 2.5RC3?

I ask because this doesn't seem to be working on my learning chat app.

When I start a peer up (Peer1) it does getRemoteAdverts & then published its advert (with a login name tag) locally & remotely.

When another peer (Peer2) starts up it does the same thing.

However, Peer1 can't see Peer2, even though Peer2 has just done a remotePublish.
Peer1 does find Peer2 when it does its heartbeat getRemoteAdverts, which I do every minute on all peers!?!?!?

Also, even though Peer2 can see Peer1 it can't establish an outputPipe to Peer1 until Peer1 can eventually see Peer2! Is this expected? I'd have thought that as long as a Peer has an advert to use it would be able to use it to make a pipe connection!?!?!?

If I then start a 3rd peer up, it might never get an advert from Peer1 or Peer2; even though its done a getRemoteAdvert & a remotePublish when it started up.
Again, Peer1 & 2 can see it (ie. they have its advert) - but can't send a message because Peer3 can't see them!?!??

All very confusing, not to say annoying. Especially as I thought I'd understood the discovery process & that it'd now work.
All my peers are running on the same PC & so on the same sub-net. They're all EDGE peers - which I think should work on the same sub-net / PC.

Anyway, my code is attached for those wanting to pull it apart to see what I'm doing wrong.

Cheers

Pete

PS. Also, I noticed that sometimes a peer will have its own advert in its cache twice.
Is this because I do a publish & a remotePublish at start up?
Even though remotePublish is supposed to not publish locally (according to the javaDoc)!?!?!

Message was edited by: siggyuke

Message was edited by: siggyuke

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bondolo
Offline
Joined: 2003-06-11
Points: 0

> I read in the Brendon Wilson book that a call to remotePublish

> publishes a peers advert to all other peers on the

> same Peer Group as the peer - so that, as I see it,

> all other peers on the network pick this up & store

> the advert locally.

>

> Is this correct with 2.5RC3?

You should not assume that calling remotePublish() will result in other peers saving your advertisement. See remotePublish() article for more information. The summary : remotePublish() cannot guarantee that any other peer will receive or store advertisements you publish. remotePublish() is the JXTA equivalent of handing out pamphlets on a street corner. It should be assumed that nobody wants the pamphlets or reads them.

In virtually all cases locally publishing an advertisement should be sufficient.

> However, Peer1 can't see Peer2, even though Peer2 has

> just done a remotePublish.

> Peer1 does find Peer2 when it does its heartbeat

> getRemoteAdverts, which I do every minute on all

> peers!?!?!?

The JXTA Discovery service [b]cannot[/b] be used to find any or all peers! That's not what it's designed for. It does a great job at tasks like "find me a printer" but it will not even attempt tasks like "find me all printers" (or peers).

What is your application trying to achieve? Are you really looking for a specific peer or are you looking for whichever peer has a specific resource (a pipe for example). In either case, how does your application decide which peers to work with?

> All my peers are running on the same PC & so on the

> same sub-net. They're all EDGE peers - which I think

> should work on the same sub-net / PC.

ADHOC will work better for this configuration. EDGE peers rely on their Rendezvous peer for a lot of the advertisement sharing mechanisms and if there are no Rendezvous peers then they will have a hard time communicating.

Mike

siggyuke
Offline
Joined: 2007-10-08
Points: 0

Once again many thanks for the reply Bondolo.
I read your remotePublish article & I now understand the limitations of remotePublish :o)

However, even though your article explains the limitations of remotePublish, I also do a straight publish - which saves my PipeAdvert to my local cache (correct?).

Then, if another chat peer starts up it does a getRemoteAdvertisements() call, which it then continues to do every minute. I thought that this would pick up, from other peers on the same peer group, any adverts that match its search criteria. In my case I'm looking for any pipeAdvert with a name that contains a TAG (SigJxtaChat:).

It's this element of my peer chat application that seems to be 'flakey'.
That is, some peers never seem to get any response to their getRemoteAdvertisements() request, whilst others seem to get all (I've only tested 3 peers running at once so far).

[QUOTE]
The JXTA Discovery service cannot be used to find any or all peers! That's not what it's designed for. It does a great job at tasks like "find me a printer" but it will not even attempt tasks like "find me all printers" (or peers).
[/QUOTE]

I guess this is where I'm confused. If I want to develop a P2P app which needs to connect to / see ALL other same applications on a network, then can't this be done / guarenteed using JXTA?

[QUOTE]
What is your application trying to achieve?
[/QUOTE]

My application is a means I'm using to try to learn JXTA.

It's function is that of a chat application.

The application is a single entity, which communicates with other same-applications on a network.
When a user starts the app (a peer), he logs on with an ID name - this should be unique, I do a getRemoteAdverts to try to check this.
Once logged in, a user of the app can send a message to ALL other peers / pipeAdverts in its local cache, or to a specified user (peer) on the network (ie. a single pipeAdvert in its local cache)

However, at the moment - given the above mentioned 'problem' - I'm not getting a guarenteed connection to all the other same-applications on the network - ie. all the other peers with a pipeAdvert containing my TAG in its Name!?!??

This is no doubt all because of my lack of understanding as to how JXTA functions & what's available within the API, hence my constant questions to the forum :o)

[QUOTE]
ADHOC will work better for this configuration.
[/QUOTE]

I'll try altering my peer type as you suggest & see if it resolves the problem I'm having.

Cheers & thanks again

Pete

PS. One thing just occurred to me:
Are the resulting adverts returned from a call to getRemoteAdverts automatically placed in my local cache (which I've assumed is the case), or do I have to publish them there myself (within the discovertEvent method)?