Message lost

bgoetzmann bgoetzmann at sophia.symag.com
Sun Jun 27 16:40:15 EDT 2010


Hello,

Concerning the problem I encounter recently (see
http://www.jboss.org/netty/community.html#nabble-td5217198%7Ca5217198), I
wrote an example with a server and client parts that points it, starting
from the ObjectEcho example.
You will find the source code in the attached file:

http://netty-forums-and-mailing-lists.685743.n2.nabble.com/file/n5228547/objectecho2.zip
objectecho2.zip 

In the ObjectEcho example a client sent an objet that is encoded and sent to
the server; on the server part, the objet is decoded and resent (encoded) to
the client (on which it decoded).

I modified this example in the goal the client send first an objet, and then
some raw data (in my original application the content of a file is sent).

For the client part, and for each connection/pipeline, an ObjectEncoder
handler is used, and the business client handler (ObjectEchoClientHandler).
So for the client, and in the ObjectEchoClientHandler's channelConnected
method:
- the client send an object of type ArrayList (as in the original ObjectEcho
example)
- then, the ObjectEncoder is removed from the pipeline
- some data is sent, using an ChannelBuffer instance containing the bytes
coming from the String "Hello!"

For the Server part, two handler are used: a ObjectDecoder handler and the
business handler, ObjectEchoServerHandler. So in the
ObjectEchoServerHandler's messageReceived method, we trace what is received:
- if the message has the type ArrayList, we remove the ObjectDecoder
handler. Normally, the server receive first a message of this type
- otherwise, we can process the message received as a ChannelBuffer.

The server does not return a message to the client.

So what is problem?

Well, if you run the server, and then the client, the server sometimes
receive only the object, and not the ChannelBuffer instance.
In the ObjectEchoClient.java, I added a loop that connect 10 times, and with
a sleep inside: more the sleep value is low more you have chances the
Channel instance is not receive.
This is why I talk about "Message lost". 

Is there something wrong in my code? Perhaps in the way a remove handlers
from the pipelines?
I would appreciate some help in this simple scenario!


Bertrand.

-- 
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Message-lost-tp5228547p5228547.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list