@@ -21,6 +21,7 @@ import (
21
21
"tailscale.com/tailcfg"
22
22
23
23
"cdr.dev/slog"
24
+ "github.com/coder/coder/v2/agent/proto"
24
25
"github.com/coder/coder/v2/codersdk"
25
26
drpcsdk"github.com/coder/coder/v2/codersdk/drpc"
26
27
"github.com/coder/retry"
@@ -281,18 +282,22 @@ func (c *Client) DERPMapUpdates(ctx context.Context) (<-chan DERPMapUpdate, io.C
281
282
},nil
282
283
}
283
284
284
- // Listen connects to the workspace agentcoordinate WebSocket
285
+ // Listen connects to the workspace agentAPI WebSocket
285
286
// that handles connection negotiation.
286
287
func (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" )
288
289
if err != nil {
289
290
return nil ,xerrors .Errorf ("parse url: %w" ,err )
290
291
}
292
+ q := rpcURL .Query ()
293
+ q .Add ("version" ,proto .CurrentVersion .String ())
294
+ rpcURL .RawQuery = q .Encode ()
295
+
291
296
jar ,err := cookiejar .New (nil )
292
297
if err != nil {
293
298
return nil ,xerrors .Errorf ("create cookie jar: %w" ,err )
294
299
}
295
- jar .SetCookies (coordinateURL , []* http.Cookie {{
300
+ jar .SetCookies (rpcURL , []* http.Cookie {{
296
301
Name :codersdk .SessionTokenCookie ,
297
302
Value :c .SDK .SessionToken (),
298
303
}})
@@ -301,7 +306,7 @@ func (c *Client) Listen(ctx context.Context) (drpc.Conn, error) {
301
306
Transport :c .SDK .HTTPClient .Transport ,
302
307
}
303
308
// nolint:bodyclose
304
- conn ,res ,err := websocket .Dial (ctx ,coordinateURL .String (),& websocket.DialOptions {
309
+ conn ,res ,err := websocket .Dial (ctx ,rpcURL .String (),& websocket.DialOptions {
305
310
HTTPClient :httpClient ,
306
311
})
307
312
if err != nil {