AS-Devs / signalr_flutter

A flutter plugin for .net SignalR client.
https://pub.dev/packages/signalr_flutter
MIT License
18 stars 28 forks source link

Cannot receive messages from server to my flutter apps #42

Closed rsyd29 closed 2 years ago

rsyd29 commented 2 years ago

I need help to solve my problem with my program code. When I create a new message and receive a message from the server an error occurs. When sending a message successfully entered the server, but when receiving a message from a different client the Flutter application could not receive it with an error message:

I/flutter (12014): statusChangeCallback: ConnectionStatus.connectionError I/flutter (12014): value: I/flutter (12014): response: null I/TextInputPlugin(12014): Composing region changed by the framework. Restarting the input method.

======== Exception caught by services library ====================================================== The following PlatformException was thrown during a platform message callback: PlatformException(channel-error, The handler has 1 parameters, but there are 2 values., null, null)

When the exception was thrown, this was the stack:

0 SignalR.onStatusChange (package:signalr_flutter/signalr_flutter.dart:46:7)

1 SignalRPlatformApi.setup. (package:signalr_flutter/signalr_api.dart:277:21)

2 SignalRPlatformApi.setup. (package:signalr_flutter/signalr_api.dart:270:35)

3 BasicMessageChannel.setMessageHandler. (package:flutter/src/services/platform_channel.dart:77:49)

4 BasicMessageChannel.setMessageHandler. (package:flutter/src/services/platform_channel.dart:76:47)

5 _DefaultBinaryMessenger.setMessageHandler. (package:flutter/src/services/binding.dart:389:35)

6 _DefaultBinaryMessenger.setMessageHandler. (package:flutter/src/services/binding.dart:386:46)

7 _invoke2. (dart:ui/hooks.dart:189:15)

11 _invoke2 (dart:ui/hooks.dart:188:10)

12 _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)

13 _Channel.push (dart:ui/channel_buffers.dart:132:31)

14 ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)

15 PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:544:22)

16 _dispatchPlatformMessage (dart:ui/hooks.dart:83:31)

(elided 3 frames from dart:async)

Flutter Code Initial Connection image image

Flutter Code Method sendMessage image

.Net Server Code image

rsyd29 commented 2 years ago

The issue has been resolved. The method Send method in the ChatHub class has one argument/parameter with a String data type. To be able to retrieve more than one data, use Map<String, dynamic> to String.

This is my code to learn what i mean Code Flutter Code .Net Framework

gongwangjie commented 7 months ago

Everything works fine in the debug environment. If you use the release version, you can connect to the server but cannot receive messages sent by the server. Have you encountered this situation?