http
http copied to clipboard
Unable to connect using JWT
Hi,
My Server side code is SignalR and I am unable to connect to it if I am using JWT. if I am not using JWT at server side, I am able to connect.
I am able to connect without any problem with same approach as my following Flutter code when using Postman and C# client code using web sockets.
My Flutter code:
final String token = '<The JWT Token>';
final String wsUrl ='wss://<Web Site URL>/progresshub?access_token==$token';
final wsURI = Uri.parse(wsUrl);
final channel = WebSocketChannel.connect(wsURI);
Also the following code does not return any error and channel object is empty:
try {
await channel.ready;
} on SocketException catch (e) {
debugPrint('ERROR: - SocketException - ${e.message}');
//print(e.message);
} on WebSocketChannelException catch (e) {
debugPrint('ERROR: - SocketException - ${e.message}');
}
For some reason I am able to add sink's like so:
channel.sink.add('{"protocol":"json","version":1}');
channel.sink
.add('{"type":1,"target":"AssociateJob","arguments":["$jobID"]}');
Error will raise without any location where it is when trying to listen:
channel.stream.listen(
(message) {
But onError: (error) => debugPrint('Error: ' + error) is not triggered.
Thanks for any help, AG