I have code like the following:
_, err := websocket.Dial("wss://remote-server", "", "http://localhost")
if (err == nil) {
fmt.Println("Worked!")
} else {
fmt.Println("Fail")
}
When remote-server
is down, it takes 60s to timeout. I found websocket.SetDeadline
(http://godoc.org/code.google.com/p/go.net/websocket#Conn.SetDeadline), but I don't have a connection yet to apply it to. I can pass a Config
to DialConfig
, but I can't see where to specify a timeout doing that.
I found https://code.google.com/p/go-wiki/wiki/Timeouts, is this how I have to do it? How do I correctly pass the error code back from the goroutine?