gpt4 book ai didi

SignalR 给出 'The ConnectionId is in the incorrect format'

转载 作者:行者123 更新时间:2023-12-03 23:24:35 25 4
gpt4 key购买 nike

我有一个 SignalR 项目,该项目在我的开发环境中正常运行,但是一旦将其转移到生产环境中,几乎每个调用都会因错误而失败

The ConnectionId is in the incorrect format.



我在 StackOverflow 上看到了一些关于相同错误消息的其他项目,但没有一个有帮助的解决方案。

我正在使用 SignalR 2.0.2 和 SignalR Scaleout with SQL Server ,实际上是 SignalR 的负载平衡器,它使用 SQL Server 进行协调。

Event code: 3005 Event message: An unhandled exception has occurred. Event time: 2/11/2014 9:11:27 PM Event time (UTC): 2/12/2014 3:11:27 AM Event ID: cff1fd93fa6d4b83b1848078a905371c Event sequence: 73 Event occurrence: 10 Event detail code: 0 Application information:

Application domain: /LM/W3SVC/2/ROOT-3-130366479327251392 
Trust level: Full
Application Virtual Path: /
Application Path: C:\inetpub\wwwroot\<remvoved>
Machine name: BSDUSHC1WW09 Process information:
Process ID: 7088
Process name: w3wp.exe
Account name: <remvoved> Exception information:
Exception type: InvalidOperationException
Exception message: The ConnectionId is in the incorrect format. at

Microsoft.AspNet.SignalR.PersistentConnection.GetConnectionId(HostContext context, String connectionToken) at Microsoft.AspNet.SignalR.PersistentConnection.ProcessRequest(HostContext context) at Microsoft.AspNet.SignalR.Hubs.HubDispatcher.ProcessRequest(HostContext context) at Microsoft.AspNet.SignalR.PersistentConnection.ProcessRequest(IDictionary`2 environment) at Microsoft.Owin.Mapping.MapMiddleware.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar) at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Request information: Request URL: http:///signalr/connect?transport=serverSentEvents&connectionToken=GZlhDBCjkD1/bL1rc4Rlq2PVKYRs0B9nN7b71cU/E6x7sCsFvR1DqM/rBnDhg+URwkYyBlGmrczV59XIn/goyt9x0xXOd8Gs3Qswo1oXqSttH2QPO548C0fbdBvvlUupzS4S0Rl+aShoQwnj+qFDpA==&connectionData=[{"Name":""}]

Request path: /signalr/connect 
User host address: 10.240.14.26
User: <remvoved>
Is authenticated: True
Authentication Type: Negotiate
Thread account name: <remvoved> Thread information:
Thread ID: 23
Thread account name: <remvoved>
Is impersonating: False
Stack trace: at Microsoft.AspNet.SignalR.PersistentConnection.GetConnectionId(HostContext

context, String connectionToken) at Microsoft.AspNet.SignalR.PersistentConnection.ProcessRequest(HostContext context) at Microsoft.AspNet.SignalR.Hubs.HubDispatcher.ProcessRequest(HostContext context) at Microsoft.AspNet.SignalR.PersistentConnection.ProcessRequest(IDictionary`2 environment) at Microsoft.Owin.Mapping.MapMiddleware.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar) at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

最佳答案

就像对使用 Session 的 ASP.NET 网站进行负载平衡一样,带有 SQL Server Scaleout 的 SignalR 要求处理 SignalR 请求的所有服务器 必须共享机器 key .

SignalR 的文档中没有明显提到这一点,所以我必须假设 connectionToken上面的事件日志消息是使用机器 key 加密的。当应用程序访问服务器 1 时,它会被分配一个使用该机器的机器 key 生成的 connectionToken。如果应用程序随后使用分配的 connectionToken 访问服务器 2,则机器 2 无法解密 token ,除非它具有匹配的机器 key 。

网上有无数关于如何设置机器 key 的资源,所以我只留下最简单的一个。单击 IIS 8(也可能是 7)中的网站并打开机器 key 设置。点击Generate Keys在右侧的操作 Pane 中。取消选中 Validation Key 下的“为每个应用程序生成唯一 key ”复选框。和 Decryption Key部分。

关于SignalR 给出 'The ConnectionId is in the incorrect format',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21855744/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com