Close websocket heartbeat explicitly when unexpected closure received
This commit is contained in:
		@@ -18,8 +18,10 @@ package remotecommand
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"context"
 | 
						"context"
 | 
				
			||||||
 | 
						"errors"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
 | 
						"net"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
	"sync"
 | 
						"sync"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
@@ -476,9 +478,15 @@ func (h *heartbeat) start() {
 | 
				
			|||||||
				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)
 | 
				
			||||||
				// Continue, in case this is a transient failure.
 | 
									if errors.Is(err, gwebsocket.ErrCloseSent) {
 | 
				
			||||||
				// c.conn.CloseChan above will tell us when the connection is
 | 
										continue
 | 
				
			||||||
				// actually closed.
 | 
									} else if e, ok := err.(net.Error); ok && e.Temporary() {
 | 
				
			||||||
 | 
										// Continue, in case this is a transient failure.
 | 
				
			||||||
 | 
										// c.conn.CloseChan above will tell us when the connection is
 | 
				
			||||||
 | 
										// actually closed.
 | 
				
			||||||
 | 
										continue
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user