question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error flushing and closing an idle Connection

See original GitHub issue

The normal mechanism to close a connection seems to be: (from: https://github.com/netty/netty/blob/master/example/src/main/java/io/netty/example/http/snoop/HttpSnoopServerHandler.java#L129)

ctx.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);

Here is what is happening -

Channel established with a client goes idle after a successful HttpRequest/Response exchange. On detecting idle event after the configured idle timeout period, we attempt to close the channel using the above utility.

However, it seems like ctx.writeAndFlush(Unpooled.EMPTY_BUFFER) never completes and hence ChannelFutureListener.CLOSE is not invoked. Another idle event is fired after another idle timeout period and so on and this channel never gets closed.

We are suspecting that since the last request/response was successful there were no more buffers left to flush . So possibly the above statement is not achieving anything and the channel never gets closed.

Netty version Netty4-4.1.45.Final

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jsvdcommented, Jan 23, 2020

I added some more details to the scenario we’re seeing in Logstash (see here). Having the IdleStateHandler in the pipeline causes outbound messages to get stuck there until a write idle event is triggered, or something comes inbound. This causes synchronous clients that perform send(message); get(ack) to get stuck, while clients that send more than one message before requesting acks are still able to function.

[edit] to touch on @rishika728’s comment, in our case we are writing + flushing actual data, so the issue isn’t constrained to an empty buffer

0reactions
jsvdcommented, May 12, 2020

For us this change between .46 and .47 solved the issue, as we used a separate executor for the IdleStateHandler.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flush a datasource connection pool in JBoss EAP
The following CLI command will flush all idle connections from a datasource pool named "ExampleDS": Standalone Mode.
Read more >
How to flush Connection in jBoss?
I think your first suggestion can be done from JMX console and your second suggestion is about flushing the connections which are idle....
Read more >
F5 is not flushing expired TCP connections - DevCentral
Resolution: We create a new tcp profile with idle timeout of 110 secs. It seems that it fixed the connection table growth. We...
Read more >
Socket connection dies after some time being idle w/o firing ...
null) socket.close(); System.out.println("Error while connecting... ... Socket connection dies after some time being idle w/o firing event.
Read more >
Closed connections remain idle in postgres - Stack Overflow
One of the purposes of a connection pool is to not permanently open and close physical connections. You need to configure your connection...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found