Note that there are some explanatory texts on larger screens.

plurals
  1. PONetty failing to read bytes from server when write fails due to socket close by server
    primarykey
    data
    text
    <p>Netty Version: 4.0.10.Final</p> <p>I've written a client and server using Netty. Here is what client and server do.</p> <p><strong>Server:</strong> </p> <ol> <li>Wait for connection from client</li> <li>Receive messages from client</li> <li>If a message is bad, write error message (6 bytes), flush it, close the socket and do not read any unread messages in the socket. Otherwise continue reading messages. Do nothing with good messages.</li> </ol> <p><strong>Client:</strong></p> <ol> <li>Connect to server.</li> <li>After writing N good messages, write one bad message and continue writing M good messages. This process happens in a separate thread. This thread is started after the channel is active.</li> <li>If there is any response from server, log it and close the socket. (Note that server responds only when there is an error)</li> </ol> <p>I've straced both client and server. I've found that server is closing connection after writing the error message. Client began seeing broken pipe errors when writing good messages after the bad message. This is because server detected bad message and responded with error message and closed socket. connection is closed only after the write operation is complete using a listener. Client is not reading error message from server always. Earlier step (2) in client is performed in I/O thread. This caused the % of error messages received over K number of experiments to be really low (&lt;10%). After moving step (2) to separate thread, % went to (70%). In any case it is not accurate. Does netty trigger channel read if the write fails due to broken pipe? </p> <p><strong>Update 1</strong>: I'm clarifying and answering any questions asked here, so everybody can find the asked questions/clarifications at one place. "You're writing a bad message that will cause a reset, followed by good messages that you already know won't get through, and trying to read a response that may have been thrown away. It doesn't make any sense to me whatsoever" - from EJP</p> <p>-- In real world the server could treat something as bad for whatever reason client can't know in advance. For simplification, I said client intentionally sends a bad message that causes reset from server. I would like to send all good messages even if there are bad messages in the total messages.</p> <p>What I'm doing is similar to the protocol implemented by <a href="https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html#//apple_ref/doc/uid/TP40008194-CH101-SW1" rel="nofollow">Apple Push Notification Service</a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload