Skip to content
Snippets Groups Projects
Commit a04083e1 authored by ale's avatar ale
Browse files

Reset the timeout on upstream connection after writing the request

parent f377f90c
Branches
No related tags found
No related merge requests found
......@@ -552,7 +552,7 @@ var _templatesIndexHtml = []byte(`<!DOCTYPE html>
<div class="row">
<p>
<small>
Click on a stream to listen to it.<br>
Click on a stream to listen to it.
Hover on a stream to see more details.
</small>
</p>
......@@ -583,7 +583,7 @@ func templatesIndexHtml() (*asset, error) {
return nil, err
}
 
info := bindataFileInfo{name: "templates/index.html", size: 2968, mode: os.FileMode(420), modTime: time.Unix(1581689120, 0)}
info := bindataFileInfo{name: "templates/index.html", size: 2964, mode: os.FileMode(420), modTime: time.Unix(1582995315, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
......
......@@ -112,14 +112,17 @@ func doIcecastProxy(rw http.ResponseWriter, req *http.Request, target *url.URL,
return
}
defer upstream.Close()
upstream.SetDeadline(time.Now().Add(requestWriteTimeout)) // nolint: errcheck
// Send the request upstream, with a timeout so we don't get
// stuck on unresponsive TCP servers.
upstream.SetDeadline(time.Now().Add(requestWriteTimeout)) // nolint: errcheck
if err := outreq.Write(upstream); err != nil {
log.Printf("http: proxy request write error: %v", err)
rw.WriteHeader(http.StatusInternalServerError)
proxyConnectErrs.WithLabelValues(streamName, target.Host).Inc()
return
}
upstream.SetDeadline(time.Time{}) // nolint: errcheck
// Hijack the request connection. We might need to unroll the
// layers of nested WrappedWriters, until we find a
......
......@@ -114,8 +114,8 @@ func TestProxy(t *testing.T) {
}()
}
// Now wait 10 seconds.
time.Sleep(10 * time.Second)
// Now wait 30 seconds, longer than request timeouts.
time.Sleep(30 * time.Second)
stopProxyTest()
for i := 0; i < streams; i++ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment