javap2pjxta

Join existing PeerGroup in JXTA/JXSE


I have a problem using JXSE. Let's say i have a rendezVous peer and an Edge peer, not on the same local network.

The rendezVous peer create a peerGroup "test", and publish an advertisement in this group with the name "test advertisement"

Let's say i'm sure than my EdgePeer is connected to the rendezVous peer. I can find the existing group "test" with netpeerGroup.getRemoteAdvertisements().

But i don't know how to join this existing group. I tried netpeergroup.newGroup(testAdv), with testAdv = the founded peerGroupAdvertisement.

I can't find the Advertisement "test advertisement" in the "test" PeerGroup. But if i do all thats things locally, it works. Maybe i don't understand the difference on how jxta works locally and over internet.

here the code for creating or joining a group :

public void addGroup(final String name) {
    ModuleImplAdvertisement mAdv = null;
    PeerGroup group = null;
    temp = null;

    defaultGroup.getDiscoveryService().getRemoteAdvertisements(null, DiscoveryService.GROUP, 
            "Name", name, 1, new DiscoveryListener() {

                @Override
                public void discoveryEvent(DiscoveryEvent event) {
                    Enumeration<Advertisement> advs = event.getResponse().getAdvertisements();
                    while(advs.hasMoreElements()) {
                        System.out.println("groupe found");
                        PeerGroupAdvertisement adv = (PeerGroupAdvertisement) advs.nextElement();
                        System.out.println("group name : " + adv.getName());
                        try {
                            temp = defaultGroup.newGroup(adv);
                            System.out.println("group joined");
                        } catch (Exception e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }

                }
            });

    try {
        Thread.sleep(10000);
        System.out.println("waiting for group ...");
    } catch (InterruptedException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    if(temp == null) {
        try {
            System.out.println("creating new group ..");
            mAdv = defaultGroup.getAllPurposePeerGroupImplAdvertisement(); /* Getting the advertisement of implemented modules */
            temp = defaultGroup.newGroup(generatePeerGroupID(name), mAdv, name, name); /* creating & publishing the group */
            getDefaultGroup().getDiscoveryService().remotePublish(temp.getPeerGroupAdvertisement());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

Solution

  • finally found the problem. You had to start the RendezVous service on each groups, and not only the netPeerGroup.

    That's why my software works locally but not on internet.