pusher / pusher-websocket-dotnet

Pusher Channels Client Library for .NET
MIT License
112 stars 113 forks source link

System.AggregateException has been thrown while trying to connect to a private channel #85

Closed 15mgm15 closed 4 years ago

15mgm15 commented 4 years ago

Hello! I have this exception while trying to connect to a private channel. I am using PusherClient 1.1.0 on Xamarin.Forms and I am testing with an iPhone simulator and a real device.

_pusherClient = new Pusher(ApplicationSettings.PusherId, new PusherOptions
{
    Authorizer = new HttpAuthorizer("our url"),
});

_pusherClient.ConnectionStateChanged += PusherConnectionChanged;
_pusherClient.Error += PusherError;

// _subscription = our private channel
var channel = await _pusherClient.SubscribeAsync(_subscription);
channel.Subscribed += ChannelSubscribed;

channel.Bind("userUpdated", (dynamic data) =>
{
    Console.WriteLine(data);
});

await _pusherClient.ConnectAsync();

This is the exception: Screen Shot 2019-11-13 at 10 14 44

This is the inner exception:

{Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: S. Path '', line 0, position 0.
  at Newtonsoft.Json.JsonTextReader.ParseValue () [0x002b3] in <12891e825fce44a581e5bbbb579c1d49>:0 
  at Newtonsoft.Json.JsonTextReader.Read () [0x0004c] in <12891e825fce44a581e5bbbb579c1d49>:0 
  at Newtonsoft.Json.JsonReader.ReadAndMoveToContent () [0x00000] in <12891e825fce44a581e5bbbb579c1d49>:0 
  at Newtonsoft.Json.JsonReader.ReadForType (Newtonsoft.Json.Serialization.JsonContract contract, System.Boolean hasConverter) [0x0004a] in <12891e825fce44a581e5bbbb579c1d49>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) [0x000db] in <12891e825fce44a581e5bbbb579c1d49>:0 
  at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00054] in <12891e825fce44a581e5bbbb579c1d49>:0 
  at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <12891e825fce44a581e5bbbb579c1d49>:0 
  at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x0002d] in <12891e825fce44a581e5bbbb579c1d49>:0 
  at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <12891e825fce44a581e5bbbb579c1d49>:0 
  at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value) [0x00000] in <12891e825fce44a581e5bbbb579c1d49>:0 
  at Newtonsoft.Json.JsonConvert.DeserializeAnonymousType[T] (System.String value, T anonymousTypeObject) [0x00000] in <12891e825fce44a581e5bbbb579c1d49>:0 
  at PusherClient.Pusher.SubscribeToChannel (System.String channelName) [0x0008e] in <3948be5ee8fa4f22bfbd47bfe37b2beb>:0 }

If I connect to a public channel everything works correctly, do you guys have any ideas?

15mgm15 commented 4 years ago

This may be related to this: https://github.com/pusher/pusher-websocket-dotnet/issues/78