http.server can be configure with these parameters:
ReadTimeout, WriteTimeout,IdleTimeout and others
I was just playing with parameters to see in which cases would be better to configure with SSE, so following the same structured from here I just add some prints to see when the clients conects and when disconects, like:
....
notify := rw.(http.CloseNotifier).CloseNotify()
fmt.Fprintf(w, "data: .\n\n") `//I add this because [onopen][3] won´t` fire if nothing is sent when start conecting
fmt.Println(" conecting")
for {
select {
case <-notify:
fmt.Println("closing")
return
default:
// Write to the ResponseWriter
// Server Sent Events compatible
fmt.Fprintf(rw, "data: %s\n\n", <-messageChan)
// Flush the data immediatly instead of buffering it for later.
flusher.Flush()
}
}
So the only value that if I changed, it prints "closing" is WriteTimeout
but reading this article it is confuse to me this part:
Finally, Go 1.8 introduces IdleTimeout which limits server-side the amount of time a Keep-Alive connection will be kept idle before being reused
But as I said even if I change IdleTimeout
the client won't close, is it because the first time the client conects I write to it, or is it a bug?
Which of three should I change then?
Go version: 1.11.1