mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-23 21:57:30 +00:00
increases client-side websocket write deadline to 30 seconds
Kubernetes-commit: 1d4be7527f8b2d2c4eb6dcc7ef58b4c3133f6f19
This commit is contained in:
parent
1002c2f9bd
commit
f759d2e976
@ -36,13 +36,9 @@ import (
|
|||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// writeDeadline defines the time that a write to the websocket connection
|
// writeDeadline defines the time that a client-side write to the websocket
|
||||||
// must complete by, otherwise an i/o timeout occurs. The writeDeadline
|
// connection must complete before an i/o timeout occurs.
|
||||||
// has nothing to do with a response from the other websocket connection
|
const writeDeadline = 30 * time.Second
|
||||||
// endpoint; only that the message was successfully processed by the
|
|
||||||
// local websocket connection. The typical write deadline within the websocket
|
|
||||||
// library is one second.
|
|
||||||
const writeDeadline = 2 * time.Second
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ Executor = &wsStreamExecutor{}
|
_ Executor = &wsStreamExecutor{}
|
||||||
@ -65,8 +61,8 @@ const (
|
|||||||
// "pong" message before a timeout error occurs for websocket reading.
|
// "pong" message before a timeout error occurs for websocket reading.
|
||||||
// This duration must always be greater than the "pingPeriod". By defining
|
// This duration must always be greater than the "pingPeriod". By defining
|
||||||
// this deadline in terms of the ping period, we are essentially saying
|
// this deadline in terms of the ping period, we are essentially saying
|
||||||
// we can drop "X-1" (e.g. 3-1=2) pings before firing the timeout.
|
// we can drop "X-1" (e.g. 6-1=5) pings before firing the timeout.
|
||||||
pingReadDeadline = (pingPeriod * 3) + (1 * time.Second)
|
pingReadDeadline = (pingPeriod * 6) + (1 * time.Second)
|
||||||
)
|
)
|
||||||
|
|
||||||
// wsStreamExecutor handles transporting standard shell streams over an httpstream connection.
|
// wsStreamExecutor handles transporting standard shell streams over an httpstream connection.
|
||||||
@ -497,7 +493,7 @@ func (h *heartbeat) start() {
|
|||||||
// "WriteControl" does not need to be protected by a mutex. According to
|
// "WriteControl" does not need to be protected by a mutex. According to
|
||||||
// gorilla/websockets library docs: "The Close and WriteControl methods can
|
// gorilla/websockets library docs: "The Close and WriteControl methods can
|
||||||
// be called concurrently with all other methods."
|
// be called concurrently with all other methods."
|
||||||
if err := h.conn.WriteControl(gwebsocket.PingMessage, h.message, time.Now().Add(writeDeadline)); err == nil {
|
if err := h.conn.WriteControl(gwebsocket.PingMessage, h.message, time.Now().Add(pingReadDeadline)); err == nil {
|
||||||
klog.V(8).Infof("Websocket Ping succeeeded")
|
klog.V(8).Infof("Websocket Ping succeeeded")
|
||||||
} else {
|
} else {
|
||||||
klog.Errorf("Websocket Ping failed: %v", err)
|
klog.Errorf("Websocket Ping failed: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user