@@ -21,6 +21,7 @@ import (
2121 "tailscale.com/tailcfg"
2222
2323 "cdr.dev/slog"
24+ "github.com/coder/coder/v2/agent/proto"
2425 "github.com/coder/coder/v2/codersdk"
2526 drpcsdk "github.com/coder/coder/v2/codersdk/drpc"
2627 "github.com/coder/retry"
@@ -281,18 +282,22 @@ func (c *Client) DERPMapUpdates(ctx context.Context) (<-chan DERPMapUpdate, io.C
281282 }, nil
282283}
283284
284- // Listen connects to the workspace agent coordinate WebSocket
285+ // Listen connects to the workspace agent API WebSocket
285286// that handles connection negotiation.
286287func (c * Client ) Listen (ctx context.Context ) (drpc.Conn , error ) {
287- coordinateURL , err := c .SDK .URL .Parse ("/api/v2/workspaceagents/me/rpc" )
288+ rpcURL , err := c .SDK .URL .Parse ("/api/v2/workspaceagents/me/rpc" )
288289 if err != nil {
289290 return nil , xerrors .Errorf ("parse url: %w" , err )
290291 }
292+ q := rpcURL .Query ()
293+ q .Add ("version" , proto .CurrentVersion .String ())
294+ rpcURL .RawQuery = q .Encode ()
295+
291296 jar , err := cookiejar .New (nil )
292297 if err != nil {
293298 return nil , xerrors .Errorf ("create cookie jar: %w" , err )
294299 }
295- jar .SetCookies (coordinateURL , []* http.Cookie {{
300+ jar .SetCookies (rpcURL , []* http.Cookie {{
296301 Name : codersdk .SessionTokenCookie ,
297302 Value : c .SDK .SessionToken (),
298303 }})
@@ -301,7 +306,7 @@ func (c *Client) Listen(ctx context.Context) (drpc.Conn, error) {
301306 Transport : c .SDK .HTTPClient .Transport ,
302307 }
303308 // nolint:bodyclose
304- conn , res , err := websocket .Dial (ctx , coordinateURL .String (), & websocket.DialOptions {
309+ conn , res , err := websocket .Dial (ctx , rpcURL .String (), & websocket.DialOptions {
305310 HTTPClient : httpClient ,
306311 })
307312 if err != nil {
0 commit comments