You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import'package:signalr_netcore/signalr_client.dart';
//all logs are enabledLogger.root.level =Level.ALL;
Logger.root.onRecord.listen((record) {
print('${record.level.name}: ${record.time}: ${record.message}');
});
//specify hub connection optionsfinal httpConnectionOptions =newHttpConnectionOptions(
accessTokenFactory: () async=>awaitgetUserToken(),
logger: transportProtLogger,
httpClient:WebSupportingHttpClient(null,
httpClientCreateCallback: _httpClientCreateCallback),
logMessageContent:true);
//build the hub connectionfinal hubConnection =HubConnectionBuilder()
.withUrl(mainServer +'/myHub', options: httpConnectionOptions)
.configureLogging(hubProtLogger)
.withAutomaticReconnect(
retryDelays: [2000, 5000, 10000, 20000, 50000]).build();
//...
_hubConnection.on('someMessage', _handleSomeMessage);
//...void_handleSomeMessage(List<Object>? args) {
//This would never call, due to the following error in the logs:
2I/flutter (11935):SEVERE:2021-10-0900:33:20.786183: (WebSockets transport) error calling onReceive, error: type 'List<dynamic>'is not a subtype of type 'List<Object>?'
}
After some digging I figured out that error goes from JsonHubProtocol class where invocation message got parsed, e.g. :
signalr_core\json_hub_protocol.dart
classJsonHubProtocolimplementsIHubProtocol {
//....staticInvocationMessage_getInvocationMessageFromJson(
Map<String, dynamic> jsonData) {
finalMessageHeaders? headers =createMessageHeadersFromJson(jsonData["headers"]);
final message =InvocationMessage(
jsonData["target"],
//Here jsonData produces List<dynamic> instead of List<Object>
jsonData["arguments"],
jsonData["streamIds"],
headers,
jsonData["invocationId"]);
_assertNotEmptyString(
message.target, "Invalid payload for Invocation message.");
if (message.invocationId !=null) {
_assertNotEmptyString(
message.invocationId, "Invalid payload for Invocation message.");
}
return message;
}
So possible fix would be just add a cast to Object:
jsonData["arguments"]?.cast<Object>().toList(),
The text was updated successfully, but these errors were encountered:
golovin-igor
added a commit
to golovin-igor/signalr_client
that referenced
this issue
Oct 9, 2021
Hi, I can reproduce the issue
Server code (dotnet core 3.1):
Client code:
After some digging I figured out that error goes from JsonHubProtocol class where invocation message got parsed, e.g. :
signalr_core\json_hub_protocol.dart
So possible fix would be just add a cast to Object:
The text was updated successfully, but these errors were encountered: