Skip to main content

OutputPipe connection failed

21 replies [Last post]
mick_000
Offline
Joined: 2009-01-22

Hi. While trying to send a msg through a o/p pipe, I encountered some problems. Someone plz tell me the solution to it. Here is the sequence of steps and the error:

First i created a peergroup and then using that peergroup object prgp2,i tried to execute the following piece of code:

pipeService=prgp2.getPipeService();
outputPipe=pipeService.createOutputPipe(pipeAdv,-1);

I was able to obtain the pipe service for that group but i am unable to create output pipe using the peer adv. I got the msg as "output connection failed".

Also, For sending the msg is the following piece of code correct:

String data="Hello";
Message msg=new Message();
StringMessageElement sme=new StringMessageElement("DataTag",data.toString(),null);
msg.addMessageElement(null,sme);
println(msg.toString());
outputPipe.send(msg);

When i tried to print the message i received the following line:

net.jxta.endpoint.Message@18450577(1){60}

Can someone explain what the above line means??

Plz reply soon. I am struck and unable to proceed without correcting this.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
nonsense2105
Offline
Joined: 2009-05-16

Hi,

I have the same problem with the listener. How did you solved it?

EDIT: solved, deleting the cache helps a lot :o)

Message was edited by: nonsense2105

mick_000
Offline
Joined: 2009-01-22

Thanks enygma2002.

I was able to send a message thru pipes itself. Just had some problem with the shell environment.

mick_000
Offline
Joined: 2009-01-22

Thanks.

mick_000
Offline
Joined: 2009-01-22

Hi. Just clarify this doubt for me.

How long will the PipeMsgListener object wait for receiving messages??? From an edge peer i created an pipe adv and used the listener object and when a rendezvous peer using that pipe adv, created an o/p pipe and sent the msg then no msg was received. After creating an i/p pipe,the pgm stops executing and doesn't wait for msg receive event to occur.

Do I have to explicitly mention a waiting time to receive msg events?????

enygma2002
Offline
Joined: 2008-12-22

The message listener is specified when you create the input pipe. It will be waiting for messages as long as the pipe is bound to the pipe advertisement, so as log as the pipe is available.

I don`t exactly understand what you mean by the fact that the program stops executing. A reson must be supplied, an exception, something.

Without other information, I can`t say what is the cause for that behaviour.

I don`t exactly know what you are doing wrong there. I had absolutely no problems with that. You could also try to delete the cache directory jxta crates and where it stores the platformConfig. That is a common source of problems while developing and testing.

Good luck with jxtasockets! They are more suited anyway.

mick_000
Offline
Joined: 2009-01-22

Thanks dude for the info.

enygma2002
Offline
Joined: 2008-12-22

Welcomed.

mick_000
Offline
Joined: 2009-01-22

I am just not able to receive the msg sent at the receiver side. The steps done to Retrieve the msg and printing it was all correct and as per the documentation available. Still its not working. When i tried using the PipeMsgListener thing,then after this particular piece of statement

inputPipe=pipeService.createInputPipe(pipeAdv,this);

the pgm stops executing aand comes out.

Is using JxtaSockets or JxtaMulticastSocket a better option for reliable msg transfer??

enygma2002
Offline
Joined: 2008-12-22

If it's reliable communication you want, you'd better read this blog post http://blogs.sun.com/hamada/date/20050824 where the features of each communication method available in jxta are explained.

In short, if you don`t plan to implement TCP-like bahavior for normal pipes, you need jxta sockets.

mick_000
Offline
Joined: 2009-01-22

Fine. Will read it and try it out. Shall then notify the results through this thread. Anyway thanks.

mick_000
Offline
Joined: 2009-01-22

Thanks dude. I was able to create output pipe and i even got the msg as "msg successfully sent" at the sender side. But the problem now is at the receiver side, the I/P pipe is still waiting for msg and no msg is getting displayed. I used the line :

msg=inputPipe.waitForMessage();

to receive msg. The actual procedure i did was this. Just tell me if i am correct or not:

Peer B is an edge peer connected to an rendezvous peer A. Peer B creates an pipe adv of type unicast and creates an I/P pipe with that adv and also publishes that adv to Peer A.

Now, peer A retrieves the pipe adv from its local cache and creates an output pipe with that adv to send a msg.

The problem with O/P pipe is resolved but at the receiver side ie) at Peer B i am unable to receive the msg and display it.

Plz any suggestion?? I even tried with InputPipeListener thing. Still I am having trouble..

enygma2002
Offline
Joined: 2008-12-22

Please try to look at some tutorial code like the one from the Practical Jxta book found here: http://www.dawningstreams.com/practicaljxta/PracticalJXTA.zip and the official one from the JXTA guide sub-project ( https://jxta-guide.dev.java.net/ ) downloadable from there https://guest@jxta-guide.dev.java.net/svn/jxta-guide/trunk/src/guide_v2....

Tell me if you still have problems after looking over them. They helped me alot to learn basics, they could help you too.

If not, come back with questions.

Good luck!

enygma2002
Offline
Joined: 2008-12-22

What group are you using for communication?

If it is netPeerGroup, then:
- do you use the default jxta public network (I doubt it because it has been down this week)
- if you use a custom network, did you forget to set one of your peers as RENDEZVOUS ?

If a custom group, subgroup of netPeerGroup, then:
- did you forget to set one of your member peers as rendezvous for that group?

Conclusion: You need at least one accessible rendezvous peer in your current group in order to perform advertisement/peer discovery and probably pipe resolving as well (what you need).

Make sure you have a peer set as rendezvous for the group you are testing and you should be ok.

Good luck!

mick_000
Offline
Joined: 2009-01-22

This is the exception i got when i tried to create the O/P pipe:

java.io.IOException: Output Pipe could not be resolved after 1000ms.

I tried increasing the time-out value. Still it didn't work. Will it be the problem with the I/P pipe at the other end????

mick_000
Offline
Joined: 2009-01-22

Anyway thanks dude. Will try it out and shall post. I tried using shell coz when i tried to execute the program in cmd prompt two peers were unable to discover each other. Can u tell the reason for it. Or in which IDE will the pgm works fine??? Simply put in which environment did u execute the programs???

mick_000
Offline
Joined: 2009-01-22

Hi. I did try by giving as u told like:

outputPipe=pipeService.createOutputPipe(pipeAdv,100);

But still I was not able to create a output pipe. I just got an exception msg like "O/P pipe creation failed". Can U shed more light on this problem as to y i am still getting this problem?? Will explain u the process i did.

First from peer B i created a pipe adv and created a I/P pipe with it to listen for msg. Peer B publishes its pipe adv. Now Peer A retrieves that pipe adv and using that pipe adv it tried to create an O/P pipe during which i encountered this trouble. I am working currently in shell environment.

I also have this question. Can the pipe service be extracted only for default netPeerGroup or it can be done for any group we create???

Plz reply soon.

enygma2002
Offline
Joined: 2008-12-22

When you do something like netPeerGroup.createNewGroup(...), the new group inherits the default services from the netPeerGroup so you will have the pipeService in the new group as well.
The pipe service is by default enabled in any peerGroup you are currently a member of, except if you explicitly remove it.

Back to your problem... I`m not sure what is to blame. I did not work in a shell environment but could you please paste the whole exception stack trace if there is one?

Anyway, I am sorry, but I can`t help you with the jxta shell. If you need further help on the programming part, feel free to ask.

mick_000
Offline
Joined: 2009-01-22

Thanks dude. Will try it out and post my reply back in this thread.

mick_000
Offline
Joined: 2009-01-22

Thanks dude. Will try it out and post my reply back. Just watch this thread so that if i encounter any problems regarding sending and receiving msg,will post those in this thread.

Also I have this doubt, at the receiver side, I am just executing this piece of code to receive the msg. Just tell me whether it is right or wrong.

PipeService pipeService=prgp1.getPipeService();
InputPipe inputPipe=pipeService.createInputPipe(pipeAdv);
Message msg=inputPipe.poll(0);
println(msg.toString());

Once again thanks for the reply.

enygma2002
Offline
Joined: 2008-12-22

I have not used that method but it looks like a blocking method untill you receive the message.

I used the asynchron method where your listener gets called when you receive a message.

From your previous post, I looks like you have an instance of Message so it should be the right one. I think that you were just not reading it correctly.

Do some testing first and read some tutorials. What you have is a very commonly exemplified situation in jxta tutorials and things have not changed that much in time regarding this problem.

Cheers.

enygma2002
Offline
Joined: 2008-12-22

1.
I think you need to do something like:
outputPipe=pipeService.createOutputPipe(pipeAdv,100);

I`m not sure if -1 is the right value. The second argument is the time to wait for the pipe to be resolved with it's pipe advertisement and with the pipe rezolver protocol (it checks some stuff before creating a valid pipe using that advertisement.). The conclusion: You need to give it some time. (100 ms is good enough in most cases).

2.
You are creating and sending a message correctly but when you receive a message, you don`t just print it as System.out.println(message) because the toString() method of Message does not include the message's content, just the default toString().

You need to extract the data, the reverse operation of creating the message.

So you need something similar to:
println(msg.getStringElement(null, "DataTag").getString());
(the exact syntax is available in the documentation/tutorials or even autocomplete in your favourite IDE).

Good luck.