我開啓SSL,用ListenAndServeTLS
GOlang/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: 超時等待客戶端前言
什麼是它的意思是?
是您的客戶端實際發送的HTTPS請求? –
是的,目前同時服務http和https –
對不起,Daniele,我的問題是你的客戶*發送一個有效的http2請求?服務器等待10秒讓客戶端發送序言,然後放棄。 –