Comments (4)
If we put the channel back to the idle pool without closing it, the next time it is picked for reuse and the read timeout has not happened yet, it will cause problem as we are sending another request on the channel without getting the response from the first request, right? Does HTTP protocol allow sending two requests on the same socket without getting the response from the first?
from rxnetty.
ConnectionLifecycleHandler remains in the pipeline after a channel is returned to the pool. Currently the channelUnregistered() method in this handler calls connection.close() which returns the channel to the pool. The pool will remove the channel if it is already closed and not reusable.
Is channelUnregsitered() automatically called when channel is closed? If not, we just need to make connection.close() is called when channel is closed. Perhaps by overriding channelInactive()?
from rxnetty.
If we put the channel back to the idle pool without closing it
May be I was not clear in my description. I did not mean to put the channel back into the reusable pool before it is closed. I meant that; this is what will happen, if we close the connection after the request processing is over i.e. when readtimeout occurs. This was just an example. The basic problem is that we are not listening to socket close events, which can happen without user interaction, eg: Channel closed by the server.
ConnectionLifecycleHandler remains in the pipeline after a channel is returned to the pool. Currently the channelUnregistered() method in this handler calls connection.close() which returns the channel to the pool. The pool will remove the channel if it is already closed and not reusable.
In the case when we close the connection (fix for issue #21 ) after we are done, conn.close() in channelUnregistered() will be a no-op as ObservableConnection ignore multiple close on the same connection. So, this call will not do what you expect it to do i.e. have isReusable() return false in the pool implementation.
Is channelUnregsitered() automatically called when channel is closed?
Channel unregistered is called when the channel is unregistered from the eventloop which happens after channelInactive() is invoked i.e. when the channel is closed.
If not, we just need to make connection.close() is called when channel is closed. Perhaps by overriding channelInactive()?
We need to explicitly remove this channel from the pool when we get a channelInactive() event as connection.close() may have been called before and hence will be ignored as explained above.
from rxnetty.
Pull Request #95 fixes this issue. Since, now the Pool is an ObservableConnection pool, the connection.close() already invoked on the underlying connection close returns the connection to the pool, which discards the connection as it is not active.
from rxnetty.
Related Issues (20)
- Adding PipelineConfigurator in RxNetty 0.5.x HOT 1
- My async client keeps getting “Content stream is already disposed” error HOT 2
- Any plan to build RxNetty on top of RxJava 2?
- ConnectionHandler on 0.5.x-java2 branch imports rx.Observable HOT 1
- For large POSTs RxNetty seems to need to write everything before reading anything HOT 6
- ClosedChannelException while TcpClient reads from TcpServer HOT 3
- 0.5 Intuitive bytebuf handling HOT 2
- RxNetty 0.5.2 stable? HOT 4
- Create Http Client without binding it to an endpoint HOT 3
- [0.4.20] NullPointException when closing socket HOT 2
- Writes out of order when using multiple threads
- Does RxNetty support http2 multiplexing? HOT 1
- why before response.close() must response.getChannel().deregister()? HOT 2
- Unnecessary synchronised lock
- Connection Leak 0.5.2 HOT 6
- require for documentation around how backpressure works HOT 4
- HTTP POST example (REST) HOT 4
- [SECURITY] unsafeSecure() should not be used in samples HOT 1
- ResourceLeakDetector,LEAK: ByteBuf.release()
- HTTPS Server with RxNetty and existing certificate
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxnetty.