Possiedo un'applicazione SignalR funzionante che consente di collegare più client JavaScript e scambiare dati. Quando ho provato a connettersi con un client .NET ottengo il seguente errore:HttpClientException quando ci si connette all'hub funzionante dal client SignalR .NET
An exception of type 'Microsoft.AspNet.SignalR.Client.HttpClientException' occurred in mscorlib.dll but was not handled in user code
Additional information: StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Transfer-Encoding: chunked
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcRGFycmVuXERlc2t0b3BcQ29uc29sZUFwcGxpY2F0aW9uMVxXZWJBcHBsaWNhdGlvbjFcc2lnbmFsclxuZWdvdGlhdGU=?=
Cache-Control: private
Date: Thu, 28 May 2015 09:13:06 GMT
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Content-Type: text/html; charset=utf-8
}
Per rimuovere il maggior numero di variabili possibili Ho copiato il Hub in una nuova applicazione web del marchio e copiato il codice client .NET in una console applicazione. Ho ancora la stessa eccezione. Ecco il mio codice cliente:
Dim hubConnection As HubConnection
Dim chatHubProxy As IHubProxy
Public Async Sub RunTest()
System.Net.ServicePointManager.DefaultConnectionLimit = 10
hubConnection = New HubConnection("http://localhost:64400")
hubConnection.Credentials = Net.CredentialCache.DefaultCredentials
hubConnection.TraceLevel = TraceLevels.All
hubConnection.TraceWriter = Console.Out
chatHubProxy = hubConnection.CreateHubProxy("Chat")
AddHandler hubConnection.StateChanged, Sub(stateChange) Console.WriteLine("[" & DateTime.Now & "]: " & stateChange.OldState.ToString() & " => " & stateChange.NewState.ToString() & " " & hubConnection.ConnectionId)
chatHubProxy.On(Of String, String)("ReceiveMessage", Sub(from, message) Console.WriteLine(message))
Await hubConnection.Start()
End Sub
Ecco l'output della console:
09:21:54.3952161 - null - ChangeState(Disconnected, Connecting)
[28/05/2015 10:21:54]: Disconnected => Connecting
[28/05/2015 10:21:56]: Connecting => Disconnected
09:21:56.8448452 - null - Disconnected
09:21:56.8458461 - null - Transport.Dispose()
09:21:56.8468465 - null - Closed
E qui è il mio codice hub:
public class ChatHub : Hub
{
public void SendMessage(string name, string message)
{
Clients.All.ReceiveMessage(name, message);
}
}
Prova a [accendere SignalR analisi su server] (http:. //www.asp. net/signalr/panoramica/test-e-debugging/abilitazione-signalr-tracing). Eventualmente SignalR registrerà l'errore ... –