Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: remove pingWebSocket since yamux runs keepalives#11914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
spikecurtis merged 1 commit intomainfromspike/10534-no-websocket-pings
Feb 1, 2024
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 1 addition & 47 deletionscodersdk/agentsdk/agentsdk.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -205,16 +205,12 @@ func (c *Client) Listen(ctx context.Context) (drpc.Conn, error) {
returnnil,codersdk.ReadBodyAsError(res)
}

ctx,cancelFunc:=context.WithCancel(ctx)
ctx,wsNetConn:=websocketNetConn(ctx,conn,websocket.MessageBinary)
pingClosed:=pingWebSocket(ctx,c.SDK.Logger(),conn,"coordinate")
_,wsNetConn:=websocketNetConn(ctx,conn,websocket.MessageBinary)

netConn:=&closeNetConn{
Conn:wsNetConn,
closeFunc:func() {
cancelFunc()
_=conn.Close(websocket.StatusGoingAway,"Listen closed")
<-pingClosed
},
}
config:=yamux.DefaultConfig()
Expand DownExpand Up@@ -720,45 +716,3 @@ func (c *closeNetConn) Close() error {
c.closeFunc()
returnc.Conn.Close()
}

funcpingWebSocket(ctx context.Context,logger slog.Logger,conn*websocket.Conn,namestring)<-chanstruct{} {
// Ping once every 30 seconds to ensure that the websocket is alive. If we
// don't get a response within 30s we kill the websocket and reconnect.
// See: https://github.com/coder/coder/pull/5824
closed:=make(chanstruct{})
gofunc() {
deferclose(closed)
tick:=30*time.Second
ticker:=time.NewTicker(tick)
deferticker.Stop()
deferfunc() {
logger.Debug(ctx,fmt.Sprintf("%s pinger exited",name))
}()
for {
select {
case<-ctx.Done():
return
casestart:=<-ticker.C:
ctx,cancel:=context.WithTimeout(ctx,tick)

err:=conn.Ping(ctx)
iferr!=nil {
logger.Error(ctx,fmt.Sprintf("workspace agent %s ping",name),slog.Error(err))

err:=conn.Close(websocket.StatusGoingAway,"Ping failed")
iferr!=nil {
logger.Error(ctx,fmt.Sprintf("close workspace agent %s websocket",name),slog.Error(err))
}

cancel()
return
}

logger.Debug(ctx,fmt.Sprintf("got %s ping",name),slog.F("took",time.Since(start)))
cancel()
}
}
}()

returnclosed
}

[8]ページ先頭

©2009-2025 Movatter.jp