Structured message reading problem in Netty.

manishr22 manishr22 at gmail.com
Thu Apr 23 09:15:59 EDT 2009


Hi danny,

For ChannelPipeLine annotation I have tried with both options one and all.
For both i am gettig similar problem.

My client is not complaining for anything, until any exception occurs in my
server. since in my server code ehenevr any exception occurs my method is
like

@Override
	public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
		// Close the connection when an exception is raised.
		logger.log(Level.WARNING, "Unexpected exception from downstream.", e
				.getCause());
		e.getChannel().close(); //MANISH:comment this line then there won't be any
client ex
	}

Due to close() my client starts giving exception like:

Caused by: java.net.SocketException: Software caused connection abort:
socket write error
	at java.net.SocketOutputStream.socketWrite0(Native Method)
	at java.net.SocketOutputStream.socketWrite(Unknown Source)
	at java.net.SocketOutputStream.write(Unknown Source)
	at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
	at java.io.BufferedOutputStream.flush(Unknown Source)
	at
com.dvclabs.logging.client.LoggingClientImplTCP.makeRequest(LoggingClientImplTCP.java:230)

and this is logical, since there channel is closed.

Otherwise at runtime i see alaways my netty server gives exception like:

WARNING: Unexpected exception from downstream.
java.lang.IndexOutOfBoundsException
	at
org.jboss.netty.buffer.AbstractChannelBuffer.checkReadableBytes(AbstractChannelBuffer.java:547)
	at
org.jboss.netty.buffer.AbstractChannelBuffer.readBytes(AbstractChannelBuffer.java:266)
	at
com.test.netty.DiscardServerHandler.messageReceived(DiscardServerHandler.java:118)
	at
com.test.netty.DiscardServerHandler.handleUpstream(DiscardServerHandler.java:87)
	at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:293)
	at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:280)
	at
org.jboss.netty.channel.socket.nio.NioWorker.readIntoHeapBuffer(NioWorker.java:300)
	at
org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:254)
	at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:163)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

Now this may give you some idea to dig down the problem.

Regards
Manish 

Danny Tai wrote:
> 
> Hi manishr22,
> 
> I am also new to netty and not very sure of my opionion :). By using
> pipeline, we should change the ChannelPipeline annotation of
> DiscarServerHanlder from all to one, as shown in Timer example in
> setion 1.7.2. of user guide.
> BTW, would you post these runtime exceptions and client codes? I think
> that will be helpful to understand your problem exactly.
> 
> 
> On Thu, Apr 23, 2009 at 7:45 PM, manishr22 <manishr22 at gmail.com> wrote:
>>
>> Hi,
>>
>> I am new to netty and tried writing netty-server as per my requirement
>> seeing various examples. But i am not getting the result correctly.
>>
>>
>> I am trying to write a netty server that can read the that will read the
>> message-structre from normal synchronous multi-threaded client ( say 10
>> client is sending 1000 messages each ) to the server.
>>
>>
>> By message structure i mean my client is sending the message in the
>> format :
>>
>>
>> [MESSAGE 1-CLIENT 1]    message-length(first 4 byte) header length(next 4
>> byte) data (including
>>
>> header and body as specified bytes of message length and header length)
>>
>>
>> [MESSAGE 2-CLIENT 1]    message-length(first 4 byte) header length(next 4
>> byte) data (including
>>
>> header and body as specified bytes of message length and header length)
>>
>>
>> ........
>>
>> ........
>>
>> [MESSAGE 1-CLIENT 2]    message-length(first 4 byte) header length(next 4
>> byte) data (including
>>
>> header and body as specified bytes of message length and header length)
>>
>>
>> [MESSAGE 2-CLIENT 2]    message-length(first 4 byte) header length(next 4
>> byte) data (including
>>
>> header and body as specified bytes of message length and header length)
>>
>> ....
>> .....
>>
>> [For N number of client and N
>> http://n2.nabble.com/file/n2682454/netty.zip
>> netty.zip  number of messages]
>>
>> and now my netty server should read all the different messages from
>> client/s
>> and do the proper message parsing and do some business operation.
>>
>>
>> How i can implement the reading of message-structure using netty.
>>
>>
>> I saw several example and implemented something in it. but its not giving
>> the appropriate result rather i am getting exception all the time.
>>
>> The basic source code which i tried for this is also attached for
>> reference.
>>
>> Any suggestion and help with some sample code will be really appreciated.
>>
>>
>> Regards
>>
>> Manish
>>
>>
>>
>> --
>> View this message in context:
>> http://n2.nabble.com/Structured-message-reading-problem-in-Netty.-tp2682454p2682454.html
>> Sent from the Netty User Group mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> netty-users mailing list
>> netty-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/netty-users
>>
> 
> 
> 
> -- 
> Best regards,
> 
> Dai Jun or Danny Dai in english, http://guiwuu.googlepages.com
> GTalk: guiwuu at gmail.com | QQ: 93409048 | MSN: guiwuu at hotmail.com |
> Twitter: guiwuu
> 
> _______________________________________________
> 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.-tp2682454p2683112.html
Sent from the Netty User Group mailing list archive at Nabble.com.





More information about the netty-users mailing list