|
Replies:
21
-
Last Post:
May 18, 2009 8:24 AM
by: nonsense2105
|
Threads:
[
Previous
|
Next
]
|
|
|
|
|
|
OutputPipe connection failed
Posted:
Mar 4, 2009 5:02 AM
|
|
|
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.
|
|
|
|
|
|
|
Re: OutputPipe connection failed
Posted:
Mar 6, 2009 2:52 AM
in response to: mick_000
|
|
|
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.
|
|
|
|
|
|
|
|
Re: OutputPipe connection failed
Posted:
Mar 6, 2009 3:57 AM
in response to: mick_000
|
|
|
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.
|
|
|
|
|
|
|
|
Re: OutputPipe connection failed
Posted:
Mar 6, 2009 6:45 AM
in response to: mick_000
|
|
|
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.
|
|
|
|
|
|
|
|
Re: OutputPipe connection failed
Posted:
Mar 6, 2009 5:05 PM
in response to: mick_000
|
|
|
Thanks dude. Will try it out and post my reply back in this thread.
|
|
|
|
|
|
|
|
Re: OutputPipe connection failed
Posted:
Mar 7, 2009 2:57 AM
in response to: mick_000
|
|
|
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.
|
|
|
|
|
|
|
|
Re: OutputPipe connection failed
Posted:
Mar 7, 2009 3:20 AM
in response to: mick_000
|
|
|
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.
|
|
|
|
|
|
|
|
Re: OutputPipe connection failed
Posted:
Mar 7, 2009 4:22 PM
in response to: mick_000
|
|
|
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???
|
|
|
|
|
|
|
|
Re: OutputPipe connection failed
Posted:
Mar 7, 2009 5:01 PM
in response to: mick_000
|
|
|
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????
|
|
|
|
|
|
|
|
Re: OutputPipe connection failed
Posted:
Mar 8, 2009 7:31 AM
in response to: mick_000
|
|
|
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!
|
|
|
|
|
|
|
|
Re: OutputPipe connection failed
Posted:
Mar 8, 2009 7:54 AM
in response to: mick_000
|
|
|
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..
|
|
|
|
|
|
|
|
|
|
Re: OutputPipe connection failed
Posted:
Mar 8, 2009 5:25 PM
in response to: mick_000
|
|
|
Fine. Will read it and try it out. Shall then notify the results through this thread. Anyway thanks.
|
|
|
|
|
|
|
|
Re: OutputPipe connection failed
Posted:
Mar 10, 2009 1:05 AM
in response to: mick_000
|
|
|
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??
|
|
|
|
|
|
|
|
Re: OutputPipe connection failed
Posted:
Mar 10, 2009 1:22 AM
in response to: mick_000
|
|
|
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.
|
|
|
|
|
|
|
|
Re: OutputPipe connection failed
Posted:
May 18, 2009 8:07 AM
in response to: mick_000
|
|
|
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
|
|
|
|
|
|
|
|
Re: OutputPipe connection failed
Posted:
Mar 10, 2009 1:39 AM
in response to: mick_000
|
|
|
Thanks dude for the info.
|
|
|
|
|
|
|
|
Re: OutputPipe connection failed
Posted:
Mar 10, 2009 2:16 AM
in response to: mick_000
|
|
|
Welcomed.
|
|
|
|
|
|
|
|
Re: OutputPipe connection failed
Posted:
Mar 10, 2009 7:45 PM
in response to: mick_000
|
|
|
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?????
|
|
|
|
|
|
|
|
Re: OutputPipe connection failed
Posted:
Mar 11, 2009 4:51 AM
in response to: mick_000
|
|
|
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.
|
|
|
|
|
|
|
|
Re: OutputPipe connection failed
Posted:
Mar 11, 2009 5:51 AM
in response to: mick_000
|
|
|
Thanks.
|
|
|
|
|
|
|
|
Re: OutputPipe connection failed
Posted:
Mar 11, 2009 10:49 PM
in response to: mick_000
|
|
|
Thanks enygma2002.
I was able to send a message thru pipes itself. Just had some problem with the shell environment.
|
|
|
|
|