Skip to main content

Bug in waitForRendezvousConnection when Restarting the network?

7 replies [Last post]
enygma2002
Offline
Joined: 2008-12-22
Points: 0

Hi guys!

Has anyone successfully restarted the jxta network using the commands below?

-----CODE START-----
manager.startNetwork();
manager.waitForRendezvousConnection(60000); <---- returns true when connected to a rdv.
manager.stopNetwork();

manager.startNetwork();
manager.waitForRendezvousConnection(60000); <--- Immediately returns false
manager.stopNetwork();
-----CODE END-----

After debugging my code, I noticed that the NetworkManager.stopped variable is never set to false except when it is declared!

NetworkManager.stopNetwork() does :
stopped = true

but NetworkManager.startNetwork() NEVER does a stopped = false

Because of this, NetworkManager.waitForRendezvousConnection(), here:

while (started && !stopped && !rendezvous.isConnectedToRendezVous() && !rendezvous.isRendezVous()) {
--code to wait for rdv connection--
}

Immediately returns and does not notice that the network has been started again.

Can anyone please confirm this!?

Thanks.

P.S.: using jxta 2.5

Corrected code. little mixup.

Message was edited by: enygma2002

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
enygma2002
Offline
Joined: 2008-12-22
Points: 0

So, nobody will actually say that this is, in fact, a bug in the current NetworkManager class?

iiggoorr
Offline
Joined: 2008-09-22
Points: 0

Hi,

well if my testing was right and I think it was, I think I might have solution for you regarding network restarting.

public void restart() throws ConnectionException
{
try
{
tunnel.stopApp();
tunnel.unref();
tunnel=null;
world.stopApp();
world.unref();
world=null;
netManager.stopNetwork();
server.interrupt();
iPCheckThread.interrupt();
republishThread.interrupt();
//netConfig=null;
netManager=null;
System.runFinalization();
System.gc();
System.out.println("tu sam 1");
this.configureNetwork();
System.out.println("tu sam 2");
this.startNetwork(doProbing);
System.out.println("tu sam 3");
}
catch(Exception e)
{
System.out.println("greska je tu "+e.getMessage());
}

this is what I am using now for restarting, and it seems to me that everything is working now.

just for explanation.

tunnel is my private peer group.

world is net peer group.

netManager is NetworkManager.

server, IPCheckThread and republishThread are 3 threads doing some job in my solution.

configureNetwork is method that I use for instancing NetworkManager and configuring peer parameters.

startNetwork is method which I use for starting jxta network connecting to RDV peer in net peer group, finding private peergroup advertisement, conecting to private peer group and connecting to RDV peer for that group.

I didn't test connectivity with other peers jet, but System.out.println("tu sam 3"); is executed, which should mean that everything went well. (tu sam means here I am in Croatian :) ).

my startNetwork method throws exception, if connection to RDV peer fails, since no exception is thrown during restart I would say that connection to RDV is successful.

For connecting to RDV I am using method explained already :)

I hope I helped you.

enygma2002
Offline
Joined: 2008-12-22
Points: 0

Yes, I see.

You forgot to mention that you are using a custom method for waiting for RDV connection to netPeerGroup (or any group, for that matter).

This indeed, is a work-around for the problem that I will most likely use myself. Thanks.

The bug in NetworkMakager.waitForRendezVousConenction() still remains and it would be nice if the jxta dev team would provide a RendezVousService.waitForRendezVousConnection() method that could be called to block untill a conenction is established with the RDV of a group. (not just for NetPeerGroup like NetworkManager tries to do).

Any feedback from bondolo or hamada about this issue/feature request?

Thank you very much for your help Igor.

enygma2002
Offline
Joined: 2008-12-22
Points: 0

Please, can anyone confirm this bug?

Any fixdates, roadmap, anything?

Thank you once again.

enygma2002
Offline
Joined: 2008-12-22
Points: 0

Am I the only one experiencing(who tried) this?

weoweh
Offline
Joined: 2008-10-22
Points: 0

Hi,

shouldn't you do it that way?:

manager.startNetwork();
manager.waitForRendezvousConnection(60000);
manager.stopNetwork();
//manager.waitForRendezvousConnection(60000); <--- Immediately returns false
manager.startNetwork();
manager.waitForRendezvousConnection(60000);

Why waiting for a RdvConnection when the network is stopped?
Or am i missing something?

enygma2002
Offline
Joined: 2008-12-22
Points: 0

No, It is just a typo mistake(copy/paste) in the earlier post. I will edit it.

The correct code was:

-----CODE START-----
manager.startNetwork();
manager.waitForRendezvousConnection(60000); <---- returns true when connected to a rdv.
manager.stopNetwork();

manager.startNetwork();
manager.waitForRendezvousConnection(60000); <--- Immediately returns false
manager.stopNetwork();
-----CODE END-----

Thanks for noticing it!

Anyone encountered this?