SignalR Client / Server在部署到服务器时停止通信(404错误)

时间:2014-02-11 17:35:54

标签: asp.net-mvc signalr

我有一个SignalR Windows服务客户端正在调用一个MVC应用程序SignalR集线器上的方法,当它全部是localhost时正在工作。当我将MVC应用程序部署到真实服务器时,我得到404个错误,我不知道该做什么或如何解决。

客户:

protected override async void OnStart(string[] args)
        {
            eventLog1.WriteEntry("In OnStart");
            try
            {
                var hubConnection = new HubConnection("http://somesplace.com/AlphaFrontendServer/signalr", useDefaultUrl: false);
                IHubProxy alphaProxy = hubConnection.CreateHubProxy("AlphaHub");

                await hubConnection.Start();

                await alphaProxy.Invoke("Hello", "Message from Service");
            }
            catch (Exception ex)
            {
                eventLog1.WriteEntry(ex.Message);
            }
        }

服务器代码是:

public class AlphaHub : Hub
    {
        public void Hello(string message)
        {
            // We got the string from the Windows Service 
            // using SignalR. Now need to send to the clients
            Clients.All.addNewMessageToPage(message);

            // Send message to Windows Service

        }

public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);
            app.MapSignalR("/signalr", new HubConfiguration());
        }
    }

当一切都是localhost时,正在调用Hello方法。现在它生成404错误:

StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  Connection: close
  Cache-Control: private
  Date: Tue, 11 Feb 2014 17:09:41 GMT
  Server: Microsoft-IIS/8.5
  X-AspNet-Version: 4.0.30319
  X-Powered-By: ASP.NET
  Content-Length: 3510
  Content-Type: text/html; charset=utf-8
}

1 个答案:

答案 0 :(得分:0)

您应该尝试this SignalR troubleshooting guide“404 Not Found”错误部分中的建议。

404的一些可能原因包括:

  • 地址无效
  • 在调用MapSignalR之前添加的其他路径的干扰
  • 在没有无扩展名网址更新的情况下使用IIS 7或7.5
  • 损坏/过时的IIS缓存