【发布时间】:2015-06-09 19:57:50
【问题描述】:
我已经研究这个问题好几天了,我完全被难住了。我们有一个基于 node.js 的 rabbitmq 消费者,它已经在本地运行了一年多,没有任何问题。最近,我们将我们的应用程序部署到 Azure,并将 node.js 组件部署到基于窗口的 PAAS 辅助角色。我们使用 square mo amqp-lib (https://github.com/squaremo/amqp.node) 作为我们的客户端库来接收来自 RabbitMQ 的消息。该角色开始正常,可以毫无问题地处理请求,但会定期回收。
检查已部署 VM 上 C:\resources 中的 WaHostBootstrapper 日志显示如下:
[00001180:00001548, 2015/06/09, 10:01:17.385, INFO ] Getting status from client RemoteAccessAgent.exe (2816).
[00001180:00001548, 2015/06/09, 10:01:17.385, INFO ] Client reported status 0.
[00001180:00001548, 2015/06/09, 10:01:17.385, INFO ] Getting status from client WaWorkerHost.exe (1380).
[00001180:00001548, 2015/06/09, 10:01:17.385, INFO ] Client reported status 3.
[00001180:00003288, 2015/06/09, 10:01:17.385, INFO ] Sending shutdown notification to client RemoteAccessAgent.exe (2816).
[00001180:00003288, 2015/06/09, 10:01:17.416, ERROR] <- CRuntimeClient::OnRoleShutdownCallback(0x0000000000331890) =0x800706be
[00001180:00003288, 2015/06/09, 10:01:17.416, INFO ] Sending shutdown notification to client WaWorkerHost.exe (1380).
VM 上的任何其他事件日志中没有其他值得注意的内容。 我修改了角色模型启动任务,将所有控制台输出记录到一个文件中,该文件没有显示任何错误。为了更清楚地了解正在发生的事情,我使用 $ENV:NODE_DEBUG = "net,http" 启用了 http 和 net 模块的 NODE_DEBUG,然后直接从 powershell 运行启动任务。经过一段时间完美处理请求后,我得到了以下信息:
NET: 3720 destroy undefined
NET: 3720 destroy
NET: 3720 close
NET: 3720 close handle
NET: 3720 emit close
NET: 3720 afterWrite 0 { domain: null, bytes: 21, oncomplete: [Function: afterWrite] }
NET: 3720 afterWrite call cb
NET: 3720 afterWrite 0 { domain: null, bytes: 8, oncomplete: [Function: afterWrite] }
NET: 3720 afterWrite call cb
NET: 3720 onread ECONNRESET undefined undefined NaN
NET: 3720 error ECONNRESET
NET: 3720 destroy
NET: 3720 close
NET: 3720 close handle
rabbitMQ 服务器有以下日志条目:
=WARNING REPORT==== 13-Mar-2015::17:48:39 ===
closing AMQP connection <0.7072.1> (137.116.194.234:1307 -> 10.140.42.79:5672):
connection_closed_abruptly
看到这个之后,我很清楚消费者和服务器之间的某些东西正在关闭连接,导致节点进程退出(我们没有从 AMQP 连接监听错误事件),这反过来又导致角色循环。
我已设法通过使用 TCPView (sysInternals) 手动关闭与兔子服务器的连接来复制此操作。
由于这仅在部署到 Azure 时才会发生,我想肯定有一些 Azure 基础设施以肮脏的方式关闭了此连接,从而导致了问题。但是什么?
【问题讨论】:
标签: node.js azure tcp rabbitmq amqp