Occasional stream corruption

Trustin Lee (이희승) trustin at gmail.com
Tue Nov 17 07:16:10 EST 2009


Hi Mike,

On Thu, Nov 12, 2009 at 11:15 PM, MikeQ <michaelquilleash at hotmail.com> wrote:
>
> Hi all,
>
> I have a server process using netty.  Part of the netty implementation is a
> simple request/response handler. Clients connect to the server and make
> synchronous request/response calls.
>
> Occasionally I get a stream corruption on the client as if the server has
> sent some duff data or the packets got misordered.  It only happens
> sometimes, for example I can start the client up and the error occurs during
> the startup, then if I stop and start the client again it works fine.  I'm
> inclined to believe this is some threading issue in my netty handler code.
>
> My first thought is the order the packets I am sending from the server is
> getting out of order before they are physically sent.  If I only have one
> thread writing to a channel is the order of the .write() going to be the
> order they are put on the wire and received by the other end?  This would
> explain my issue.

If you write messages from multiple threads, the order of the write
requests will be mixed.  However, the content of each write request
should never get mixed.  That is, if you write "AB" and "CD" from two
threads, the resulting output could be either "ABCD" or "CDAB", while
"BACD", "ABDC", "CDBA", and "DCAB" are impossible.  If you are seeing
the abnormal corruption, please let me know.  I'd like to investigate
further with more information.

HTH

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



More information about the netty-users mailing list