Skip to content

Commit f684439

Browse files
committed
fix: use a native websocket.NetConn for agent RPC client
1 parent 92f0f66 commit f684439

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

codersdk/agentsdk/agentsdk.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,11 @@ func (c *Client) ConnectRPC(ctx context.Context) (drpc.Conn, error) {
206206
return nil, codersdk.ReadBodyAsError(res)
207207
}
208208

209-
_, wsNetConn := codersdk.WebsocketNetConn(ctx, conn, websocket.MessageBinary)
209+
// Set the read limit to 4 MiB -- about the limit for protobufs. This needs to be larger than
210+
// the default because some of our protocols can include large messages like startup scripts.
211+
conn.SetReadLimit(1 << 22)
212+
netConn := websocket.NetConn(ctx, conn, websocket.MessageBinary)
210213

211-
netConn := &closeNetConn{
212-
Conn: wsNetConn,
213-
closeFunc: func() {
214-
_ = conn.Close(websocket.StatusGoingAway, "ConnectRPC closed")
215-
},
216-
}
217214
config := yamux.DefaultConfig()
218215
config.LogOutput = nil
219216
config.Logger = slog.Stdlib(ctx, c.SDK.Logger(), slog.LevelInfo)

0 commit comments

Comments
 (0)