我有两个集线器,我正在尝试从服务器建立两个连接:
var hubConnection1 = new HubConnection("http://localhost:14382");
var proxy1 = hubRestaurantConnection.CreateHubProxy("Hub1");
hubConnection1.Start().Wait();
var hubConnection2 = new HubConnection("http://localhost:14382");
var proxy2 = hubConnection.CreateHubProxy("Hub2");
hubConnection2.Start().Wait();
hubConnection2.Start()。Wait()调用异常终止崩溃:
StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Transfer-Encoding: chunked
X-SourceFiles: =?UTF-8?B?QzpcZGV2XHdlYjJcRmxpcGRpc2hXZWJcRmxpcGRpc2guV2ViXHNpZ25hbHJcc3RhcnQ=?=
Cache-Control: private
Date: Wed, 27 May 2015 15:19:49 GMT
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Content-Type: text/html; charset=utf-8
}
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Microsoft.AspNet.SignalR.Client.HttpClientException: StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Transfer-Encoding: chunked
X-SourceFiles: =?UTF-8?B?QzpcZGV2XHdlYjJcRmxpcGRpc2hXZWJcRmxpcGRpc2guV2ViXHNpZ25hbHJcc3RhcnQ=?=
Cache-Control: private
Date: Wed, 27 May 2015 15:19:49 GMT
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Content-Type: text/html; charset=utf-8
}
我有两个集线器的原因是,一个将由具有管理员权限的用户使用,第二个用于其他用户,并且它有不同的方法。
来自javascript客户端的连接似乎工作正常。我知道集线器正在共享一个连接,但从我的设计角度来看,它没有问题。是错误还是我做错了什么?
我还试图交换创建集线器代理的顺序,而异常只发生在同一个代理上。
答案 0 :(得分:0)
使用相同的HubConnection创建多个hubproxies:
var hubConnection = new HubConnection("http://localhost:14382");
var proxy1 = hubConnection.CreateHubProxy("Hub1");
var proxy2 = hubConnection.CreateHubProxy("Hub2");
hubConnection.Start().Wait();