jamiewest / signalr_core

ASP.NET Core SignalR Dart Client
https://pub.dev/packages/signalr_core
MIT License
90 stars 58 forks source link

Exception: Failed to invoke 'SendMessage' due to an error on the server. #76

Closed Mu2tini closed 2 years ago

Mu2tini commented 2 years ago

Hi!

I'm trying to invoke sending a message to the server but get this: "Exception: Failed to invoke 'SendMessage' due to an error on the server."

Set up connection works but not sending messages. I'm running:

await _connection!.invoke('SendMessage', args: ['Bob', 'Says hi!']);

This is my hub on the backend:

public class ChatHub : Hub { public async Task SendMessage(List<dynamic> data) { await Clients.All.SendAsync("ReceiveMessage", data[1] as string); } }

Running this from a web client works but not from the signalr_core client. Do you know what might be wrong here? I'm using .Net Core 5.

Mu2tini commented 2 years ago

Was using the arguments in Invoke as well as backend hub method in wrong way. So no issue on library. Check this guys PingPong game as a good reference for using it correctly. https://github.com/Ilushnik