0

This plugin ...

https://pub.dev/packages/ably_flutter

... asked me to do this ...

ably.ClientOptions options = ably.ClientOptions(
  clientId : '...',
  authUrl : '...',
  authHeaders : {'Authorization' : '...'},
);
ably.Realtime realtime = await ably.Realtime(options : options);

... before gave me this ...

E/DartMessenger(12893): Uncaught exception in binary message listener

E/DartMessenger(12893): java.lang.ClassCastException: java.util.HashMap cannot be cast to io.ably.lib.types.Param[]

... and I don't know what else to do.

I thought it's because the backend responded wrong format data to Ably, so it was failed to convert it to ably.tokenParams type at app end. But backend guys told me there's nothing wrong at their end.

Greatly appreciate your help thank you.

stackunderflow
  • 1,492
  • 1
  • 23
  • 53
  • Hi @stackunderflow . Thanks for raising this question. I am an SDK developer at Ably and wanted to let you know that it's a bug in our side. I have created an issue on Github if you wanted to track the status : https://github.com/ably/ably-flutter/issues/444 – ikbal Oct 04 '22 at 14:03
  • @ikbal thank you for your reply. it's great to hear from ably dev team themselves. actually i've find a workaround for this issue. i posted it as the answer for my question. thanks again – stackunderflow Oct 04 '22 at 15:28

1 Answers1

1

It's working either way using authCallback instead of authUrl and clientId, where TokenRequest or TokenDetais generated from data returned by back-end.

Authenticate with signed TokenRequest

ably.ClientOptions(
  key : token //Authentication token
  authCallback : (ably.TokenParams params) => ably.TokenRequest.fromMap(...)
);

Authenticate with Ably JWT

ably.ClientOptions(
  authCallback : (ably.TokenParams params) => ably.TokenDetails.fromMap(...)
);
stackunderflow
  • 1,492
  • 1
  • 23
  • 53