Dart WebSocket client template doesn't support query parameters from channel bindings
The Dart WebSocket client template doesn't extract or use query parameters defined in channel bindings, unlike the Python template. This prevents authentication tokens and other important parameters from being passed to WebSocket connections.
When a channel defines query parameters in its bindings (e.g., auth_token for authentication), the generated JavaScript client should:
- Accept these parameters in the constructor
- Automatically append them to the WebSocket URL as query strings
// Expected generated code
ExampleClient({String? url, String? auth_token})
: _url = _buildUrl(url ?? 'wss://default-url', auth_token);
static String _buildUrl(String baseUrl, String? authToken) {
if (authToken == null) return baseUrl;
return '$baseUrl?auth_token=$authToken';
}
You're right—the Dart WebSocket client template does not currently extract or use query parameters from channel bindings, so parameters like auth_token can't be passed as part of the WebSocket URL. This is a known limitation and contrasts with the Python template, which uses a shared helper (getQueryParams) to extract query parameters and append them to the URL in the generated client constructor (source).
To bring the Dart template in line with the Python template, you would need to:
- Use the
getQueryParamshelper to extract query parameters from channel bindings. - Update the generated Dart client constructor to accept these parameters as arguments.
- Build a query string from the provided arguments and append it to the WebSocket URL before connecting.
The Python template provides a clear model for this: it exposes query parameters as constructor arguments, assembles them into a query string, and appends them to the URL if present (example). The Dart template would need similar logic added to its constructor and connection setup (current Dart constructor).
Recent work on shared WebSocket client template components (see PR #1728) introduced query parameter variables, which could be reused to keep the implementation consistent across languages (source).
In summary: the Dart template does not yet support this, but the path forward is clear—mirror the Python template's approach using the shared helpers and update the constructor and URL assembly logic accordingly.
To reply, just mention @dosu.
Docs are dead. Just use Dosu.
@Adi-204, please take a look at this!
@batchu5 you can work on issue or if you are not interest please do update issue description and add it is open for contribution.
yep, I'm interested, will raise a PR soon.
@batchu5 are you working on it ? If not ,I can take this one.
@SHUBHANSHU602, you can work on it :)
Thanks !
I'm working on this!
sure @batchu5 !
still working @batchu5 ?
@batchu5 If you're not working on this can i take it?