SignalR - 发布版本:服务器协商失败

时间:2014-08-04 10:10:12

标签: c# xamarin signalr portable-class-library signalr.client

我在Xamarin应用程序中遇到了一个恼人的错误。该解决方案包含一个Android项目和一个可移植的类库。在便携式类库中,我有一个类,它使用方法InitiateConnection

与SignalR集线器通信
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();

只要我在调试版本中使用上述方法,它就能正常工作并且我正在接收数据。如果在发布版本中调用此方法,则会抛出异常。首先是Xamarin未处理的例外情况。继续推送后,我收到以下异常:

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`

在方法的最后一行抛出了异常:await conn.Start();

如果我读取任务I的Exception属性,我会看到与上面相同的错误。 NuGet包和最近发布的Xamarin组件都出现了这个问题。有谁知道问题是什么?

0 个答案:

没有答案