5

I am facing an annoying error within my Xamarin application. The solution contains an Android-project and a portable class library. Within the portable class library I have a class which communicates with a SignalR hub with a method InitiateConnection

HubConnection conn= new HubConnection(_url);

// Some events will be registrated on the HubConnection here...

if (!string.IsNullOrWhiteSpace(_userName))
{
    conn.Credentials = new System.Net.NetworkCredential(_userName, _password);
}
await conn.Start();

As soon as I'm using the method above in a debug build it's working properly and I'm receiving data. If this method will be called in a release build it throws an exception. Firstly an unhandled exception from Xamarin. After pushing continue I'm receiving the following exception:

System.InvalidOperationException: Server negotiation failed.


Unhandled Exception:
System.InvalidOperationException: Server negotiation failed.
at Microsoft.AspNet.SignalR.Client.Transports.TransportHelper.<GetNegotiationResponse>b__1 (System.String raw) [0x00000] in <filename unknown>:0 
at Microsoft.AspNet.SignalR.TaskAsyncHelper+<>c__DisplayClass19`2[System.String,Microsoft.AspNet.SignalR.Client.NegotiationResponse].<Then>b__17 (System.Threading.Tasks.Task`1 t) [0x00000] in <filename unknown>:0 
at Microsoft.AspNet.SignalR.TaskAsyncHelper+TaskRunners`2+<>c__DisplayClass3a[System.String,Microsoft.AspNet.SignalR.Client.NegotiationResponse].<RunTask>b__39 (System.Threading.Tasks.Task`1 t) [0x00000] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0 
at Monitoring.Client.MonitorProxy+<InitiateConnection>d__0.MoveNe
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: Server negotiation failed.
at Microsoft.AspNet.SignalR.Client.Transports.TransportHelper.<GetNegotiationResponse>b__1 (System.String raw) [0x00000] in <filename unknown>:0 
 at Microsoft.AspNet.SignalR.TaskAsyncHelper+<>c__DisplayClass19`2[System.String,Microsoft.AspNet.SignalR.Client.NegotiationResponse].<Then>b__17 (System.Threading.Tasks.Task`1 t) [0x00000] in <filename unknown>:0 
at Microsoft.AspNet.SignalR.TaskAsyncHelper+TaskRunners`2+<>c__DisplayClass3a[System.String,Microsoft.AspNet.SignalR.Client.NegotiationResponse].<RunTask>b__39 (System.Threading.Tasks.Task`1 t) [0x00000] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0 
at Monitoring.Client.MonitorProxy+<InitiateConnectio`

The exception got thrown at the last line in the method: await conn.Start();

If I read the Exception property of the Task I'm seeing the same error as above. The problem is happening with both the NuGet package and recently released Xamarin Component. Does anyone know what the problem is?

bkardol
  • 1,258
  • 1
  • 20
  • 32

0 Answers0