diff --git a/main.go b/main.go index 206100e..d54f4bd 100644 --- a/main.go +++ b/main.go @@ -56,6 +56,7 @@ type UpstreamContext struct { var upstreamContexts = make(map[string]*UpstreamContext) var upstreamContextLock = &sync.Mutex{} +var emptySlice []byte func GetUpstreamContext(name string) *UpstreamContext { upstreamContextLock.Lock() @@ -127,6 +128,8 @@ func upstreamFiber(name string) { fmt.Printf("Connecting to upstream for stream %s ...\n", name) r := (func() *http.Response { for { + // Notify with an empty slice, so the client fiber could kick dead clients. + ctx.upstreamChan <- emptySlice r, err := client.Do(req) if err != nil { fmt.Fprintf(os.Stderr, "Unable to request %s for stream %s: %v\n", upstreams[name], name, err)