Skip to main content

Questions about JxtaBiDiPipe

7 replies [Last post]
chaosie
Offline
Joined: 2007-07-11
Points: 0

Hello everyone, I am in trouble with JxtaBiDiPipe.Hope you can help me....
The client closes the JxtaBiDiPipe to the JxtaServerPipe every time after data is exchanged( a conversation ).The codes below show the process.

Client:
biDiPipe.connect(peerGroup, null, curRemotePeer, 60000, null);
biDiPipe.sendMessage(reqMsg);
biDiPipe.getMessage(60000);
biDiPipe.close();

Server:
JxtaBiDiPipe pipe = pipeServer.accept();
pipe.getMessage(6000);
pipe.sendMessage(message);
pipe.close();

However the third conversation between the two peers causes an exception,which is "java.io.IOException: Pipe already bound.". I don`t understand that`s why.
Looking foward to your help..

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
chaosie
Offline
Joined: 2007-07-11
Points: 0

Hello, hamada.
Both of the server and client run on the same node. Is this the key to the problem?

hamada
Offline
Joined: 2003-06-12
Points: 0

it's possible that a bug exist. Normally once a pipe is bound, subsequent bind should fail, so perhaps bound was not reset during close.
Are you running the tip of the tree?

Also running on the same is not an issue. I would also recommend that you keep the pipe if you intend to send more messages.

jimbosi
Offline
Joined: 2007-06-14
Points: 0

Hi Chaos,

If a pipe is "bound", that means it is or has been connected to another pipe. I'm guessing you're doing something like:

biDiPipe.connect(peerGroup, null, curRemotePeer, 60000, null);
biDiPipe.sendMessage(reqMsg);
biDiPipe.getMessage(60000);
biDiPipe.close();
...
biDiPipe.connect(peerGroup, null, curRemotePeer, 60000, null);

If this is what you're doing, you'll get an error because (I'm guessing here) the JxtaBiDiPipe class has a whole bunch of variables inside it that can only be initialised when you create an instance of the class.

You should probably be doing this:

biDiPipe.connect(peerGroup, null, curRemotePeer, 60000, null);
biDiPipe.sendMessage(reqMsg);
biDiPipe.getMessage(60000);
biDiPipe.close();
...
biDiPipe = new JxtaBiDiPipe(...)
biDiPipe.connect(peerGroup, null, curRemotePeer, 60000, null);
...

Also, if you're expecting to send more messages between the pipes, you shouldn't close them every time you send a message. Closing a pipe essentially disconnects the two endpoints. You can safely leave the pipes open until you're sure the two peers have nothing more to communicate with each other.

hope that helped,

jim

chaosie
Offline
Joined: 2007-07-11
Points: 0

hamada, jimbosi, thank you so much!
But a new problem occurred..
My application is used to share files. It discoveries current online peers and lists. When you choose one peer, a pipe is connected to the one, through which command is sent and shared directory is returned. Then you double-click the directories listed to enter a deeper directory, however, problems happens because the command can't reach the server any more. During the whole course, the pipe isn't closed, as you said.
Begging for your help....

hamada
Offline
Joined: 2003-06-12
Points: 0

You need to tell us a few things :

which version of JXTA are you using? if not, the latest, can try the latest to see if it exhibits the same behavior.

Also, if you're still experiencing issues, then I suggest you turn on logging, look and report errors/exceptions if any.

hamada
Offline
Joined: 2003-06-12
Points: 0

Is this using the same JxtaBiDiPipe object? is it to the same node?

chaosie
Offline
Joined: 2007-07-11
Points: 0

Yes, the same.
I don`t quite understand what "Pipe already bound" means. It seems not related to whether the pipe is closed.