Comments (4)
I don't see a neat way to close cmux down at all. I could be misreading the docs but even though it says ErrListenerClosed is supposed to be returned, I get a net.OpError instead that says "use of closed network connection".
from cmux.
Any progress on this? I'm using cmux to share HTTP/REST and gRPC on the same port as I slowly transition from the former to the later. Both of those have graceful shutdown options, but I find that cmux.Serve()
does not throw a clear error (I get the same thing as @shabbyrobe), making my life difficult.
from cmux.
may be some thing like a Stop method which not only does the m.root.Close() and also make sure it closes other connections .
`defer func() {
close(m.donec)
wg.Wait()
for _, sl := range m.sls {
close(sl.l.connc)
// Drain the connections enqueued for the listener.
for c := range sl.l.connc {
_ = c.Close()
}
}
}()`
Most of it is there in defer func of Serve.
so we need to make sure it doesn't happen at two places .
from cmux.
So, while a “graceful shutdown” is in part available through PR-69 to call a Close()
function, the unexported muxListener
type that wraps the net.Listener
that is the actual net.Listener
set during the cmux.New()
, does not implement its own Close()
function, so when either a gRPC or HTTP server is told to gracefully shutdown, it will passthrough close the main net.Listener
port, breaking cmux.CMux.Serve
and any other service also setup.
Ideally, the cmux.CMux.Close()
would handle closing the actual net.Listener
(so new connections are rejected) and then the Close()
from each of the muxListener
children will only close their own individual acceptance channels, which will then allow all pending Accept
to be drained, and then the server shutdown once all the outstanding handlers finish.
from cmux.
Related Issues (20)
- Possibly move examples_test.go to examples package HOT 1
- Server unexpectedly doesn't receive traffic from cmux.Any() HOT 1
- Udp support?
- Add benchmarks
- badly-behaved client can deadlock server stopping HOT 3
- Cannot get Matchers to mux h2c gRPC and HTTP2(REST) requests HOT 4
- It's hard to extend protocol HOT 3
- how to write client codeto gprc connect HOT 2
- Doesn't work with grpc-go's hello world example HOT 2
- Pull In Downstream Fixes HOT 1
- Cannot check closed error with errors.Is HOT 1
- Multiplexing gRPC and Prometheus metrics services using Google Cloud Run
- Matching based on URL HOT 1
- Cmux example HOT 1
- Close not working properly on gRPC graceful stop HOT 1
- Multiplexing gRPC & HTTP handlers with H2C+Prior Knowledge HOT 4
- socks5 matcher not working HOT 2
- http2 matcher not working with net/http HOT 2
- I don't understand why calling source.Read() might block?
- HTTP1Fast matcher omits PATCH HOT 2
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 cmux.