SignalR客户端内部服务器错误500

时间:2016-07-26 03:13:38

标签: c# winforms signalr

我使用了来自msdn

的SignalR Demo

服务器启动后。我尝试登录到客户端,我收到以下错误。如果有什么事我做错了,请你告诉我。

StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:

{

  Date: Tue, 26 Jul 2016 03:02:41 GMT
  Server: Microsoft-HTTPAPI/2.0
  Content-Length: 0

}

但是当我使用netstat -aon|findstr 8080时,服务运行正常,只是客户端无法连接到signalR服务器!

客户端连接代码:

/*This is client to connect the server*/

private async void ConnectAsync()
{
    Connection = new HubConnection(ServerURI);
    Connection.Closed += Connection_Closed;
    HubProxy = Connection.CreateHubProxy("MyHub");
    //Handle incoming event from server: use Invoke to write to console from SignalR's thread
    HubProxy.On<string, string>("AddMessage", (name, message) =>
        this.Invoke((Action)(() =>
            RichTextBoxConsole.AppendText(String.Format("{0}: {1}" + Environment.NewLine, name, message))
        ))
    );
    try
    {
        Connection.JsonSerializer.TypeNameHandling = TypeNameHandling.Auto;
        await Connection.Start();
    }
    catch (HttpRequestException)
    {
        StatusText.Text = "Unable to connect to server: Start server before connecting clients.";
        //No connection: Don't enable Send button or show chat UI
        return;
    }
    catch (Exception ex)
    {
        StatusText.Text = "ErrorCode 500, Internal Server Error: " + ex.ToString();
        return;
    }

    //Activate UI
    SignInPanel.Visible = false;
    ChatPanel.Visible = true;
    ButtonSend.Enabled = true;
    TextBoxMessage.Focus();
    RichTextBoxConsole.AppendText("Connected to server at " + ServerURI + Environment.NewLine);
}

当客户端连接到ServerURI时,它将导致异常:ErrorCode 500,内部服务器错误

0 个答案:

没有答案