SignalR - Release Build: Server Negotiate Error

An annoying error is encountered in my Xamarin app. The solution contains an Android project and a portable class library. Inside a Portable Class Library, I have a class that communicates with the SignalR Hub using the methodInitiateConnection

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();

      

Once I use the method above in a debug build, it works correctly and I get the data. If this method is called in a release build, it will throw an exception. First, an unhandled exception from Xamarin. After clicking continues, I get 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`

      

An exception was thrown on the last line of the method: await conn.Start();

If I read the Exception property for the Task, I see the same error as above. The issue occurs with both the NuGet package and the recently released Xamarin. Does anyone know what the problem is?

+3


source to share





All Articles