Structured message reading problem in Netty.

"이희승 (Trustin Lee)" trustin at gmail.com
Wed Jun 10 03:41:35 EDT 2009


Could you tell us what exception exactly you are getting? (stack trace)

On 2009-06-05 오후 4:38, manishr22 wrote:
> 
> 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
>>
>>
> 


-- 
— Trustin Lee, http://gleamynode.net/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 258 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20090610/19a50ce1/attachment.bin 


More information about the netty-users mailing list