AS-Devs / signalr_flutter

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

Platform Error: java.lang.IllegalStateException: Expected STRING but was BEGIN_OBJECT / BEGIN_ARRAY at path $ #6

Closed Chyur closed 3 years ago

Chyur commented 3 years ago

Hi, Using the following three functions, I cannot get the params from a server in two cases. (I cannot change the code on the server.)

Server code: public class NotificationHub : Hub { ...

public int GetCurrentState()
{
  return MvcApplication.CurrentState;
}

public Dictionary<string, ushort[]> GetDictionaryMParams()
{
  Dictionary<string, ushort[]> dictionary = null;

  var controller = DependencyResolver.Current.GetService<MParamsController>();
  MParams mParams = controller.GetFirstMParams();
  if(mParams != null) {
    dictionary = new Dictionary<string, ushort[]>();
    AddMDictionary(dictionary, "par1", mParams.par1);
    AddMDictionary(dictionary, "par2", mParams.par2);
  }
  return dictionary;
}

public List<MParams> GetListMParams(int idFrom)
{
  return  DependencyResolver.Current.GetService<MParamsController>().GetListMParams(idFrom);
}

}

Function GetCurrentState() is invoked without error - it works well.

Log for GetDictionaryMParams():

[log] Message from _onStatusChange(String status): status = Connected [log] Message from _onStatusChange(String status): status = java.lang.IllegalStateException: Expected STRING but was BEGIN_OBJECT at path $ I/flutter ( 4216): Platform Error: java.lang.IllegalStateException: Expected STRING but was BEGIN_OBJECT at path $

Log for GetListMParams(int idFrom):

[log] Message from _onStatusChange(String status): status = Connected [log] Message from _onStatusChange(String status): status = java.lang.IllegalStateException: Expected STRING but was BEGIN_ARRAY at path $ I/flutter ( 4489): Platform Error: java.lang.IllegalStateException: Expected STRING but was BEGIN_ARRAY at path $

But if I use Microsoft.AspNet.SignalR.Client.Cpp from my VC++ application, all functions work well.

Is it possible to fix these errors if it is a bug or something else? Thanks

AyonAB commented 3 years ago

@Chyur grab the latest version from pub. This issue should be gone now.

Chyur commented 3 years ago

@AyonAB thank you. Now the functions are invoked without any errors.