|
|
|
|
Help needed please
Posted:
Nov 3, 2009 11:38 PM
|
|
|
I have developed two peers; one as a service requestor and the other as a service distributor. Service here implies the transfer of a package of files from the distributor peer to the requestor peer.
The problem I am having right now is how to get these two peers to see one another over the network. When I have both peers on the same machine, it just works fine. The requestor publishes an advertisement and the distributor finds it and connets to the requestor and starts talking to it.
I want the same senario to happen when the peers are not on the same machine, however these machines are part of a LAN.
Any hint what I might be missing here or just might have done wrong?
Thanks and regards,
Ayman
|
|
|
|
|
|
|
Re: Help needed please
Posted:
Nov 4, 2009 12:44 AM
in response to: aymanshargawi
|
|
|
Maybe you could post the complete error or waring message which could help to identify the causes. from my experience,if two peers could find each other on the same machine,they could work well in the same subnet with default configuration.It's necessary to configure when it's time to communicate across subnet. It sames that by default,two peers find each other by means of multicasting which annouce itself to all the nodes in the same subnet
|
|
|
|
|
|
|
|
Re: Help needed please
Posted:
Nov 4, 2009 2:29 AM
in response to: flyroom
|
|
|
Thank you for replying.
The two peers are configured exactly the same and each one runs on its machine with no problems or errors. Only thing is that when one publishes its pipe advertisement, the other one just does not find it; however, it finds it if they were instantiated on the same machine.!
Could it be the security policy of the LAN on which these two peers reside?
This is the instantiaion code in both peers that connects them to the network and makes them part of the netPeerGroup.
public PeerGroup connectToJxta(NetworkManager manager) { try { manager = new NetworkManager(NetworkManager.ConfigMode.ADHOC, this.getPeerName(), new File(new File("local"), this.getPeerName()).toURI()); manager.startNetwork(); netPeerGroup = manager.getNetPeerGroup(); return netPeerGroup; } catch(Exception e) { lastErr = "Unable to Connect to JXTA Network for the following reason:\n" + e.getMessage(); e.printStackTrace(); return null; } }
Hope that will give you a hint of how it is set up to work.
Ayman
|
|
|
|
|
|
|
|
Re: Help needed please
Posted:
Nov 4, 2009 4:15 AM
in response to: aymanshargawi
|
|
|
Hi! please, post the code of how you publish your adv and how you get it, it seems like a publish mistake.
|
|
|
|
|
|
|
|
Re: Help needed please
Posted:
Nov 4, 2009 5:04 AM
in response to: deniswsrosa
|
|
|
Although it works when I start it on the same machine, but this is the code to publish the adv anyways:
public boolean publishPipeAdvertisement(PipeAdvertisement pipeAdv) { long lifetime = 60 * 2 * 1000L; long expiration = 60 * 2 * 1000L; discoveryService = getDiscoveryService(netPeerGroup); if(null != discoveryService) { try { if(!getLastPublishedAd().equals(pipeAdv.getName())) { discoveryService.publish(pipeAdv, lifetime, expiration); display.append( "\n"+pipeAdv.getName() + " ID: " + pipeAdv.getPipeID() + " is published locally\n"); discoveryService.remotePublish(pipeAdv,expiration); display.append( "\n"+pipeAdv.getName() + " ID: " + pipeAdv.getPipeID() + " is published remotely\n"); setLastPublishedAd(pipeAdv.getName()); }
return true; } catch(Exception e) { lastErr = "Unable to Publish the Input Pipe for the following reason:\n" + e.getMessage(); e.printStackTrace(); return false; } } else return false;
}
This is the code to find the adv:
private Advertisement findAdvertisement(String crit, String val)throws IOException { Enumeration localAdv = null; long lifetime = 60 * 2 * 1000L; long expiration = 60 * 2 * 1000L; long waittime = 60 * 3 * 1000L;
try { if(getDiscoveryService(netPeerGroup)!= null) { display.append("\nI am here in findAdvertisement looking for " + crit + " = " + val+ "\n"); discoveryService.getLocalAdvertisements(discoveryService.ADV,crit, val); if((localAdv != null) && localAdv.hasMoreElements()) { display.append("\nlocalAdv is not null\n"); PipeAdvertisement temp = (PipeAdvertisement)localAdv.nextElement(); if(temp.getName().equals(val)) { return temp; } else { display.append("\nlocalAdv is null and now attempting to get remote advs\n"); discoveryService.getRemoteAdvertisements(// no specific peer (propagate) null, // Adv type DiscoveryService.ADV, // Attribute = any crit, // Value = any val, // one advertisement response is all we are looking for 1, // no query specific listener. we are using a global listener this);
return null; } } else { display.append("\nlocalAdv is null and now attempting to get remote advs\n"); discoveryService.getRemoteAdvertisements(// no specific peer (propagate) null, // Adv type DiscoveryService.ADV, // Attribute = any crit, // Value = any val, // one advertisement response is all we are looking for 1, // no query specific listener. we are using a global listener this);
return null; } } else { lastErr = "DiscoveryService is not available"; throw new IOException("DiscoveryService is null"); } } catch(Exception e) { lastErr = "Unable to Find advertisemetns for the following reason:\n" + e.getMessage(); e.printStackTrace(); return null; }
}
I'll be gone for now. I'll check your reply when I'm back.
Thanks for helping out.
Ayman
|
|
|
|
|
|
|
|
Re: Help needed please
Posted:
Nov 7, 2009 4:36 AM
in response to: deniswsrosa
|
|
|
OK I have figured why it does not work. That's because the LAN on which these two peers reside blocks most ports from communicating by default except for the email system and stuff.
What I did was set up an isolated LAN and tested the system. The result was a complete success.
Thank you for trying to help out.
Ayman
|
|
|
|
|