部署在远程计算机上时,SignalR无法正常工作

时间:2013-02-27 05:52:48

标签: c# asp.net-mvc signalr signalr-hub

我开发了一个网络聊天应用程序,并且遇到了一个奇怪的问题。应用程序在我的本地计算机上工作正常,但只是卡在远程计算机上。

完全迷失了,如何提供有关我的问题的线索(如果有跟踪问题的技巧请咨询),我从$.connection.hub.error得到的唯一错误是

Protocol error: Unknown transport.

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: System.InvalidOperationException: Protocol error: Unknown transport.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[InvalidOperationException: Protocol error: Unknown transport.]
   Microsoft.AspNet.SignalR.PersistentConnection.ProcessRequest(HostContext context) +866
   Microsoft.AspNet.SignalR.Hubs.HubDispatcher.ProcessRequest(HostContext context) +174
   Microsoft.AspNet.SignalR.Owin.CallHandler.Invoke(IDictionary`2 environment) +628
   Microsoft.AspNet.SignalR.Owin.Handlers.HubDispatcherHandler.Invoke(IDictionary`2 environment) +222
   Microsoft.Owin.Host.SystemWeb.OwinCallContext.Execute() +55
   Microsoft.Owin.Host.SystemWeb.OwinHttpHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object extraData) +259

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   Microsoft.Owin.Host.SystemWeb.CallContextAsyncResult.End(IAsyncResult result) +110
   Microsoft.Owin.Host.SystemWeb.OwinHttpHandler.EndProcessRequest(IAsyncResult result) +7
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8836913
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

这是控制台日志提供的内容。

SignalR: Negotiating with '<root_url>/signalr/negotiate'. jquery.signalR-1.0.0-rc2.js:54
SignalR: Attempting to connect to SSE endpoint '<root_url>/signalr/connect?transport=serverSentEv…2fc32a4&connectionData=%5B%7B%22name%22%3A%22xmppservicehub%22%7D%5D&tid=7' jquery.signalR-1.0.0-rc2.js:54
SignalR: EventSource timed out trying to connect jquery.signalR-1.0.0-rc2.js:54
SignalR: EventSource readyState: 0 jquery.signalR-1.0.0-rc2.js:54
SignalR: EventSource calling close() jquery.signalR-1.0.0-rc2.js:54
SignalR: This browser supports SSE, skipping Forever Frame. jquery.signalR-1.0.0-rc2.js:54
SignalR: SignalR: Initializing long polling connection with server. jquery.signalR-1.0.0-rc2.js:54
SignalR: Attempting to connect to '<root_url>/signalr/connect?transport=longPolling&…fc32a4&connectionData=%5B%7B%22name%22%3A%22xmppservicehub%22%7D%5D&tid=10' using longPolling. jquery.signalR-1.0.0-rc2.js:54
SignalR: Longpolling connected jquery.signalR-1.0.0-rc2.js:54
SignalR: Attempting to connect to '<root_url>/signalr?transport=longPolling&connecti…%7CS%2C1%7CT%2C0%7CQ%2C0&groups=%5B%22XmppServiceHub.howtodemo%22%5D&tid=2' using longPolling. jquery.signalR-1.0.0-rc2.js:54
SignalR: Attempting to connect to '<root_url>/signalr?transport=longPolling&connecti…%7CR%2C0%7CS%2C1%7CT%2C0&groups=%5B%22XmppServiceHub.howtodemo%22%5D&tid=8' using longPolling. jquery.signalR-1.0.0-rc2.js:54
SignalR: Attempting to connect to '<root_url>/signalr?transport=longPolling&connecti…%7CR%2C0%7CS%2C1%7CT%2C0&groups=%5B%22XmppServiceHub.howtodemo%22%5D&tid=5' using longPolling. jquery.signalR-1.0.0-rc2.js:54
SignalR: An error occurred using longPolling. Status = error. <html>
    <head>
        <title>Protocol error: Unknown transport.</title>

供参考:

  • 服务器端是一个SignalR Hub,描述了只读会话 here
  • Asp.Net MVC 4
  • IIS 6 Webserver

我迷失了如何提供任何线索,如果这些信息不够,请告诉我应该提供哪些信息。

修改

使用nuget(版本1.0.0)中的最新库更新后,我得到了以下错误(仍然是相同的控制台日志,在本地计算机上仍可正常工作,但在远程计算机上)

[ObjectDisposedException]: The CancellationTokenSource has been disposed.

Server stack trace: 
   at System.Threading.CancellationTokenSource.ThrowIfDisposed()
   at System.Threading.CancellationTokenRegistration.Dispose()
   at Microsoft.AspNet.SignalR.Infrastructure.CancellationTokenExtensions.<>c__DisplayClass6`1.<SafeRegister>b__1()
   at Microsoft.AspNet.SignalR.Infrastructure.DisposableAction.Dispose(Boolean disposing)
   at Microsoft.AspNet.SignalR.Infrastructure.DisposableAction.Dispose()
   at Microsoft.AspNet.SignalR.Transports.TransportHeartbeat.EndConnection(ConnectionMetadata metadata)
   at Microsoft.AspNet.SignalR.Transports.TransportHeartbeat.AddConnection(ITrackingConnection connection)
   at Microsoft.AspNet.SignalR.Transports.LongPollingTransport.ProcessRequest(ITransportConnection connection)
   at Microsoft.AspNet.SignalR.PersistentConnection.ProcessRequest(HostContext context)
   at Microsoft.AspNet.SignalR.Hubs.HubDispatcher.ProcessRequest(HostContext context)
   at Microsoft.AspNet.SignalR.Owin.CallHandler.Invoke(IDictionary`2 environment)
   at Microsoft.AspNet.SignalR.Owin.Handlers.HubDispatcherHandler.Invoke(IDictionary`2 environment)
   at Microsoft.Owin.Host.SystemWeb.OwinCallContext.Execute()
   at Microsoft.Owin.Host.SystemWeb.OwinHttpHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object extraData)

Exception rethrown at [0]: 
   at Microsoft.Owin.Host.SystemWeb.Utils.<>c__DisplayClass1.<GetRethrowWithNoStackLossDelegate>b__0(Exception ex)
   at Microsoft.Owin.Host.SystemWeb.Utils.RethrowWithOriginalStack(Exception ex)
   at Microsoft.Owin.Host.SystemWeb.CallContextAsyncResult.End(IAsyncResult result)
   at Microsoft.Owin.Host.SystemWeb.OwinHttpHandler.EndProcessRequest(IAsyncResult result)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

提前致谢

2 个答案:

答案 0 :(得分:2)

SignalR不支持&lt; IIS 7。

修改 我们不支持IIS&lt; 7但是可以设置配置以支持它。

看起来你的应用程序正在运行,但是你在这里遇到了这个问题https://github.com/SignalR/SignalR/issues/1549,它已经在下一个版本中得到修复。

答案 1 :(得分:0)

当您提供错误的中心网址时,也会出现传输问题。即使您在URL末尾添加一个额外的正斜杠,也会出现此问题。