2016-06-09 120 views
2

我開啓SSL,用ListenAndServeTLSGOlang/HTTPS:超時等待客戶前言

func main() { serverMux := http.NewServeMux() serverMux.HandleFunc("/v1/ws1", handler1)
 serverMux.HandleFunc("/v1/ws2", handler2) serverMux.HandleFunc("/v1/ws3", handler3)
 serverMux.HandleFunc("/static/", handlerStatic(http.FileServer(http.Dir("/var/project/")))) go func() { wsSSLServer := &http.Server{ Addr: ":443", Handler: serverMux, ReadTimeout: 15 * time.Second, WriteTimeout: 15 * time.Second, } certPath := "/etc/letsencrypt/live/example.com/" fmt.Println(wsSSLServer.ListenAndServeTLS(certPath+"fullchain.pem", certPath+"privkey.pem")) }() wsServer := &http.Server{ Addr: ":80", Handler: serverMux, ReadTimeout: 15 * time.Second, WriteTimeout: 15 * time.Second, } fmt.Println(wsServer.ListenAndServe()) }

,現在我得到很多這些錯誤的日誌:

http2:服務器:錯誤讀取客戶端前言xxxx:xxxxx: 超時等待客戶端前言

什麼是它的意思是?

+0

是您的客戶端實際發送的HTTPS請求? –

+0

是的,目前同時服務http和https –

+0

對不起,Daniele,我的問題是你的客戶*發送一個有效的http2請求?服務器等待10秒讓客戶端發送序言,然後放棄。 –

回答

0

我得到了同樣的錯誤使用Firefox作爲客戶端。 重新生成SSL密鑰/證書解決了問題,我猜證書已過期。

對於本地主機發展: openssl req -nodes -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days XXX -subj '/CN=localhost'