Arsene
Arsene

Reputation: 1067

Netty - Channel write fail to send the data to the client

I am developing a socket based app using Netty 3.6.x. However I am encountering an issue with the channel.write. This is what I did: First whenever the channel goes to the CONNECTED state I write to the channel and it is successful. Now when the server goes done I try reconnect to it and when the channel is connected I try write to it but this time it seems that the server did not receive the data.

Also when I check the write state it say done.

What can be the issue?

Upvotes: 0

Views: 1588

Answers (2)

Arsene
Arsene

Reputation: 1067

Thank you Norman. I have fixed the issue. The issue was that I was using the the ChannelFuture listener and I realized that I was setting the pipeline and the transcoder within that callback. So when I sent the data over the wire it is not encoded properly. To solve I have to handle every in the channelConnected and channelCLosed method.

Upvotes: 0

Norman Maurer
Norman Maurer

Reputation: 23557

You should check if the ChannelFuture was failed and if so inspect the the error via:

ChannelFuture future = ...
if (!future.isSuccess()) {
    future.getCause().printStacktrace();
} 

This should show you the reason why it failed.

Upvotes: 2

Related Questions