Structured message reading problem in Netty.
manishr22
manishr22 at gmail.com
Fri Jun 5 03:38:58 EDT 2009
Hi Trustin,
I was able to resolve that problem.
I was also trying to send back acknowledgment back from server to the client
for each client's message.
Again to be more specific, my client is made of normal socket (NOT USING
NETTY).
I tried using echo example for this like:
e.getChannel().write(firstMessage);
and other way i tried as:
byte[] bytes = null;
ChannelBuffer returnMessage;
try {
bytes = BytesConversionUtil.intToByteArray(msgCountFromClt); //
msgCountFromClt- int varibale
returnMessage = ChannelBuffers.buffer(bytes.length);
for (int i = 0; i < returnMessage.capacity(); i++) {
returnMessage.writeByte((byte) i);
}
Channel local = event.getChannel();
if (local.isWritable()) {
local.write(returnMessage);
}
} catch (LoggingFrameworkUtilException i) {
logger.error("Error while sending acknowledgement. ", i);
} finally {
bytes = null;
}
but this always fails and ends with exception. Any suggestion why my Netty
server is not able to write back the message to normal socket client?
Regards
Manish Ranjan
Trustin Lee-2 wrote:
>
> Hi Manish,
>
> On Fri, May 1, 2009 at 7:54 PM, manishr22 <manishr22 at gmail.com> wrote:
>>
>> Hi Frederic,
>>
>> Thanks for your clarification. But the problem is, we are trying to make
>> a
>> asynchronous TCP/Ip communication then there should be any dependency on
>> client.
>>
>> In my existing code what you said is exactly right.
>>
>> - I have my normal client (non-netty) it creates TCP connection and send
>> as
>> much data it wants and terminates.
>> - I believe as much data client has written on the socket should be read
>> by
>> server.
>> - In my case i have several such client and they can send as many number
>> of
>> message to the server they want. how come i understand when to send back
>> "end of transmission" to the client, then only client should disconnect.
>> - The workaround is my client should send "bye/final" after all its
>> messages
>> then in the echo from server send back the same and then only i should
>> close
>> connection from client. But this way i am synchronizing my server with
>> client.
>> - If i have my server with normal socket, even though my client
>> connection
>> goes down, server will still be reading all buffered socket data without
>> any
>> problem.
>> - In what sense netty is differentiating here.
>
> Netty also should finish reading all data and then find that the
> connection has been closed. That's how O/S stream I/O works so the
> expected behavior you described will always be achieved with any
> socket application. Please let me know if you are still experiencing
> the problem and how I can reproduce the problem as simply as possible.
>
> HTH,
>
> — Trustin Lee, http://gleamynode.net/
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>
>
--
View this message in context: http://n2.nabble.com/Structured-message-reading-problem-in-Netty.-tp2682454p3028971.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list