Not receiving all data after attempting to close the channel.

Stephen Pape Stephen.Pape.ctr at RL.af.mil
Mon Nov 23 10:25:56 EST 2009


Hi Trustin,

I finally narrowed down the problem to be my own.
I had made soLinger a configurable option, and it was initialized to 0 by default. 

For future reference, when it's set to zero:
"
A close() returns immediately. The underlying stack discards any unsent data, and, in the case of connection-oriented protocols such as TCP, sends a RST (reset) to the peer (this is termed a hard or abortive close). All subsequent attempts by the peer's application to read()/recv() data will result in an ECONNRESET.
"

So I'll use a default value of -1 and not call setOption() if the value is still at -1.

Thanks!

-Stephen

-----Original Message-----
From: Trustin Lee [via Netty Forums and Mailing Lists] [mailto:ml-node+4041435-2019587827 at n2.nabble.com] 
Sent: Friday, November 20, 2009 10:26 PM
To: Pape, Stephen R CTR USAF AFMC AFRL/RISE
Subject: Re: Not receiving all data after attempting to close the channel.

Hi Stephen, 

On Fri, Nov 20, 2009 at 4:24 AM, Stephen Pape 
<[hidden email] <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=4041435&i=0> > wrote: 

> 
> Thanks for the reply. Isn't what you're doing essentially the same thing? 
> You're getting notified via operationComplete() that the write was 
> (supposedly) completed, then allowing execution to continue. That seems like 
> what I'm doing, except I immediately close the channel. 
> 
> I found a similar thread about this topic here: 
> http://www.jboss.org/netty/community.html#nabble-td3398725|a3398725 
> 
> 
> Trustin Lee wrote: 
>> 
>> You can achieve this pretty simply: 
>> 
>>   channel.write(ChannelBuffers.EMPTY_BUFFER) 
>>          .addListener(ChannelFutureListener.CLOSE); 
>> 
> 
> Given that response, I assumed my method should work. I was doing the same 
> thing, adding a listener to close after the last write completed. I wasn't 
> using an empty buffer because my channel pipeline couldn't accept a 
> ChannelBuffer directly. 
> 
> Is there some reason that the channel can't be closed immediately after a 
> write has completed? 

I think you are closing the connection properly.  I never experienced 
the same problem, but it worths an investigation just in case.   Can 
you reproduce the problem with loopback connection?  Do you have a 
simple application that reproduces the problem? 

Thanks 
T 

_______________________________________________ 
netty-users mailing list 
[hidden email] <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=4041435&i=1>  
https://lists.jboss.org/mailman/listinfo/netty-users

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


________________________________

View message @ http://n2.nabble.com/Not-receiving-all-data-after-attempting-to-close-the-channel-tp4033482p4041435.html 
To unsubscribe from Re: Not receiving all data after attempting to close the channel., click here < (link removed) > . 


 
-- 
View this message in context: http://n2.nabble.com/Not-receiving-all-data-after-attempting-to-close-the-channel-tp4033482p4051709.html
Sent from the Netty User Group mailing list archive at Nabble.com.



More information about the netty-users mailing list