SignalR 2.2和ARR3.0负载均衡 [英] SignalR 2.2 and ARR3.0 Load balancing

查看:246
本文介绍了SignalR 2.2和ARR3.0负载均衡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Signalr2.2 Web应用程序并将其托管在IIS-8中.在这里,我尝试使用ARR3.0为我的应用程序实现负载平衡.在我的服务器场中,我连接了两台服务器,并将路由规则设置为加权轮询".每个服务器都有一个带有HTML页面的javascript客户端.当我访问任何服务器的HTML页面时,请求已按预期路由,但是我的HTML页面中出现此错误,并且信号器未连接

I am using signalr2.2 web application and hosted in IIS-8. Here I tried to implement load balancing for my application using ARR3.0. In my server farm I connected two servers and set the routing rule as 'weighted round robin'. Every server has a javascript client with HTML page. While I am accessing HTML page of any server the request has been routed as expected but I am having this error in my html page and signalr doesn't get connected

WebSocket连接到WS://mydomain.com/signalr/connect运输=&的WebSockets放大器; clientProtocol = 1.5&安培; connectionToken = x9rAfatyMm3TbqzrYKL1K37Z4tKrUTH7bwNmSItW55Z0ms6pe43YiQGFOmaHMyT%2BpmGz62ukt4tha72vPcJhdqLtIvsQvqvY15oYGv69JjzSuuiSL7v2l%2FccZT6tQa3Z&安培; connectionData =%5B%7B%22name%22%3A%22chathub %22%7D%5D& tid = 1'失败:WebSocket握手时出错:意外的响应代码:400

WebSocket connection to 'ws://mydomain.com/signalr/connect?transport=webSockets&clientProtocol=1.5&connectionToken=x9rAfatyMm3TbqzrYKL1K37Z4tKrUTH7bwNmSItW55Z0ms6pe43YiQGFOmaHMyT%2BpmGz62ukt4tha72vPcJhdqLtIvsQvqvY15oYGv69JjzSuuiSL7v2l%2FccZT6tQa3Z&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D&tid=1' failed: Error during WebSocket handshake: Unexpected response code: 400

如果我在服务器场中使该服务器的任何人脱机,则Signalr可以正常工作,并且不会引发任何错误.帮我找到解决方案.

如果我通过.net客户端应用程序与信号发送器服务器进行通信,则会引发以下错误

If I communicate signalr server from my .net client application it will throw the following error

启动请求期间出错.停止连接.

Error during start request. Stopping the connection.

推荐答案

我也遇到了这个问题.从更深的角度看,错误是:The connection id is in the incorrect format.仔细搜索之后,我读到某个地方,在运行服务器场环境时,服务器需要共享相同的机器密钥,可以在IIS中对其进行配置.

I had this problem as well. Looking deeper, the error is: The connection id is in the incorrect format. After googling a bit, I read somewhere that when running a farm environment, the servers need to share the same machine key, which can be configured in IIS.

为此,请按照下列步骤操作:

To this, follow these steps:

  • 打开连接到服务器场中任何服务器的IIS.
  • 在服务器节点中,打开右窗格中的 Machine Key 选项
  • 在右侧菜单中,单击生成密钥
  • 取消选中验证密钥解密密钥Generate a unique key for each application选项.
  • 复制生成的两个键(例如粘贴在记事本中)
  • 确保服务器场中的所有服务器都共享相同的密钥(ARR服务器不需要此密钥),您可能需要在它们中重复以上步骤(也许您不立即使用共享配置).
  • Open the IIS connecting to any of your servers in the farm.
  • In the server node, open the Machine Key option in the right pane
  • In the right menu, click Generate Keys
  • Uncheck the Generate a unique key for each application option for both Validation key and Decryption key.
  • Copy the two keys generated (e.g paste in notepad)
  • Make sure all servers in the farm share this same keys (the ARR server doesn't need this), you might need to repeat the steps above in them (maybe you don't as soon as they use Shared Configuration).

此外,您需要确保每个服务器中的应用程序使用相同的身份.例如,选择您的应用程序节点(如果是这样,则选择站点节点),在右键菜单中选择基本设置,然后选择连接为... .如果选择的选项是应用程序用户,那么您需要检查应用程序池的配置方式.如果它使用网络服务(就像我的一样),您仍然会遇到问题,因为每个服务器都使用自己的凭据,但是您必须确保它们使用相同的身份.

Also, you need to make sure your application in each server use the same Identity. For example, select your application node (or site node if it's the case), in right menu select Basic Settings, then Connect as.... If the selected option is Application user, then you need to check how is your Application Pool configured. If it uses Network Service (as were mine), you'll still have problems, because each server uses its own credentials, but you have to make sure they use the same Identity.

在我的方案中,我必须创建一个有权访问服务器场中每台服务器的用户,并使应用程序使用同一用户.这样做之后,我的问题才得以解决.

In my scenario, I had to create a user with access to every server in the farm, and make the application use this same user. Only after doing this my problem was solved.

这篇关于SignalR 2.2和ARR3.0负载均衡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆