Skip to main content

[JXSE 2.5] JxtaBidiPipe connection issue

6 replies [Last post]
hades82
Offline
Joined: 2008-11-20

Hi,
I'm quite new in JXTA development so I don't know if the next case is cause i'm doing something wrong (most probably) or something different. That's the case:

I have two classes. Former is a JxtaServerPipe waiting for JxtaBidiPipe connections (server.accept()). Latter has a JxtaBidiPipe trying to connect to the serverPipe (bidi.connect(...)). Well, when both programs are runnning it seems the connection is established because in the server appears

25-may-2010 19:08:21 net.jxta.impl.pipe.InputPipeImpl
INFO: Creating InputPipe for urn:jxta:uuid-59616261646162614E50472050325033A06AB1FDED0F4AC6BE0ECC4AD077190704 of type JxtaUnicast with listener
25-may-2010 19:09:10 net.jxta.impl.endpoint.tcp.TcpMessenger
INFO: Creating new TCP Connection to : tcp://x.x.x.x:9746 / x.x.x.x:9746

On the other hand, at same time in the JxtaBidiPipe client it appears:

25-may-2010 19:09:10 net.jxta.impl.pipe.InputPipeImpl
INFO: Creating InputPipe for urn:jxta:uuid-59616261646162614E5047205032503370FC70CC94B54B0FA59B8DEE48CF3D3204 of type JxtaUnicast with listener
25-may-2010 19:09:10 net.jxta.impl.endpoint.tcp.TcpMessenger
INFO: Connection from x.x.x.x:39057

After this, the client would send a message to the server, but actually it crashes with an IOException throwed by the connect() method, cause the timeout is exceeded. I don't know why it happens, and I suppose that both peers see each other (otherwise it wouldn't appear the INFO shown above, isn't it?)

Any idea why it happens? Thank you very much.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
hades82
Offline
Joined: 2008-11-20

Hi again,

I write only to say.. problem fixed!! You were rigth, it was a problem with the advertisement I connected to. Now I use the correct advertisement and the peers can communicate without problems.

Altough I want to make another question. Now I want the pipe ID to be persistent, I mean if I run the peer n times I want that the pipe ID it publish be the same each execution. Does JXTA has any mechanism to save that kind of information in the .jxta directory? or I must to create a file and write all the info I want to save.

Thank you again. Bye.

adamman71
Offline
Joined: 2007-01-31

When creating the Pipe ID, you can specify a seed:

IDFactory.newPipeID(PeerGroupID groupID, byte[] seed)

If you always specify the same seed with the same PG id, you will always get the same PipeID.

For example:

String PipeName = "My pipe's name";
IDFactory.newPipeID(MyPGID, PipeName.getBytes());

hades82
Offline
Joined: 2008-11-20

Thank you very much adamman, I will use your advice on my code cause the solution I found was a "hard-coded" ID. Now I will use the peer name as seed

Sorry for not response before but I've been working in other projects and it was impossible for me to answer.

Thank you again!!!

hades82
Offline
Joined: 2008-11-20

Hi again,

First of all, I must say that both peers can see each other. At least when I try to find the other peer with the DiscoveryService (getRemoteAdvertisements(...) method) there's a positive match.

Well, Ariel the IOException is:

java.io.IOException: connection timeout
at net.jxta.util.JxtaBiDiPipe.connect(JxtaBiDiPipe.java:362)
at net.jxta.util.JxtaBiDiPipe.connect(JxtaBiDiPipe.java:300)
at pack.MyPeer.connectPipe(MyPeer.java:396)
at pack.MyPeer.ratePeer(MyPeer.java:498)
at pack.Trial.main(Trial.java:47)

galato, the only info I have that makes me think the connection is established is what I showed you in my first post (INFO: Connection from x.x.x.x:39057). Both peers are in the same public LAN without NAT between them.

I guess if I'm making a mistake cause before I call the constructor of serverPipe I create the PipeAdv and I publish it with the DiscoveryService.publish()(and remotePublish()) methods. I don't know if when I create the serverPipe it binds automatically and that what I doing is redundant.

I'll search to see if the PipeAdv I get is really the one I want to connect to.
Thanks so much again.

galato
Offline
Joined: 2007-07-06

Do your peers show that the connection has been established? Are your peers residing in the same LAN or in separate LANs. Are they public or behind a NAT?

ariel_ro
Offline
Joined: 2009-12-28

Can you expand your IOException?

It might be a problem with advertisements. Are you sure your server socket is binded to the same advertisement as the one that the client connects to? It happened for me in the case of JxtaSocket.