edgard / iperf3_exporter

Simple server that probes iPerf3 endpoints and exports results via HTTP for Prometheus consumption
Creative Commons Zero v1.0 Universal
63 stars 26 forks source link

Set HTTP Server Timeouts #2

Closed seanmalloy closed 5 years ago

seanmalloy commented 5 years ago

By default the web server from Go Lang's net/http package does not set timeouts.

https://github.com/edgard/iperf3_exporter/blob/master/iperf3_exporter.go#L221

You can set a proper timeout by doing something like this ...

srv := &http.Server{
    Addr:         "0.0.0.0:8080",
    ReadTimeout:  5 * time.Second,
    WriteTimeout: 5 * time.Second,
}
log.Fatal(srv.ListenAndServe())
edgard commented 5 years ago

Good catch. Closed with a8ec208