Open ChaseRay1989 opened 1 year ago
我现在是每个服务都单独部署,例如例子里面的connetor,chat,master,这三个服务都是单独的部署,然后chat和connector是可以动态的扩容伸缩,可以新增实例,也可以回收部分实例,所以会出现与master断开连接的这种操作
[master-server-1 mqttClient.js] mqtt socket is close, remote server host: 10.65.189.10, port: 3005
master 自己连自己? 有这种操作? 这个ip对吗?
其实也是可以master连master的,就是部署了两个master,一个做slave,然后主master同步信息给slave,如果主master挂了,slave顶上,其他服务连这个slave
但是我看源码,好像如果是某个服务断开了,会触发master不断的重连?不知道有没看错,this.closed这个值好像会一直被改成true
2023-08-08T00:03:28.439] [ERROR] pinus-admin - [master-server-1 mqttClient.js] mqtt socket is close, remote server host: 10.65.189.10, port: 3005Error: at Logger.pLogger. [as error] (/home/gpx/app/avg-game-engine-2d/node_modules/pinus-logger/lib/logger.ts:76:34)
at Connection. (/home/gpx/app/avg-game-engine-2d/node_modules/pinus-admin/lib/protocol/mqtt/mqttClient.ts:108:20)
at Connection.emit (node:events:390:28)
at Socket.emit (node:events:390:28)
at TCP. (node:net:687:12)
[2023-08-08T00:04:28.440] [INFO] pinus-admin - [master-server-1 mqttClient.js] reconnect delay 60 s
[2023-08-08T00:04:28.442] [ERROR] pinus-admin - [master-server-1 mqttClient.js] mqtt socket is error, remote server host: 10.65.189.10, port: 3005Error:
at Logger.pLogger. [as error] (/home/gpx/app/avg-game-engine-2d/node_modules/pinus-logger/lib/logger.ts:76:34)
at Connection. (/home/gpx/app/avg-game-engine-2d/node_modules/pinus-admin/lib/protocol/mqtt/mqttClient.ts:113:20)
at Connection.emit (node:events:390:28)
at Socket.emit (node:events:390:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
[2023-08-08T00:04:28.442] [ERROR] pinus-admin - [master-server-1 mqttClient.js] mqtt socket is close, remote server host: 10.65.189.10, port: 3005Error:
at Logger.pLogger. [as error] (/home/gpx/app/avg-game-engine-2d/node_modules/pinus-logger/lib/logger.ts:76:34)
at Connection. (/home/gpx/app/avg-game-engine-2d/node_modules/pinus-admin/lib/protocol/mqtt/mqttClient.ts:108:20)
at Connection.emit (node:events:390:28)
at Socket.emit (node:events:390:28)
at TCP. (node:net:687:12)
[2023-08-08T00:05:28.442] [INFO] pinus-admin - [master-server-1 mqttClient.js] reconnect delay 60 s
[2023-08-08T00:05:28.444] [ERROR] pinus-admin - [master-server-1 mqttClient.js] mqtt socket is error, remote server host: 10.65.189.10, port: 3005Error:
at Logger.pLogger. [as error] (/home/gpx/app/avg-game-engine-2d/node_modules/pinus-logger/lib/logger.ts:76:34)
at Connection. (/home/gpx/app/avg-game-engine-2d/node_modules/pinus-admin/lib/protocol/mqtt/mqttClient.ts:113:20)
at Connection.emit (node:events:390:28)
at Socket.emit (node:events:390:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
[2023-08-08T00:05:28.445] [ERROR] pinus-admin - [master-server-1 mqttClient.js] mqtt socket is close, remote server host: 10.65.189.10, port: 3005Error:
at Logger.pLogger. [as error] (/home/gpx/app/avg-game-engine-2d/node_modules/pinus-logger/lib/logger.ts:76:34)
at Connection. (/home/gpx/app/avg-game-engine-2d/node_modules/pinus-admin/lib/protocol/mqtt/mqttClient.ts:108:20)
at Connection.emit (node:events:390:28)
at Socket.emit (node:events:390:28)
at TCP. (node:net:687:12)
[2023-08-08T00:06:28.445] [INFO] pinus-admin - [master-server-1 mqttClient.js] reconnect delay 60 s
[2023-08-08T00:06:28.447] [ERROR] pinus-admin - [master-server-1 mqttClient.js] mqtt socket is error, remote server host: 10.65.189.10, port: 3005Error:
at Logger.pLogger. [as error] (/home/gpx/app/avg-game-engine-2d/node_modules/pinus-logger/lib/logger.ts:76:34)
at Connection. (/home/gpx/app/avg-game-engine-2d/node_modules/pinus-admin/lib/protocol/mqtt/mqttClient.ts:113:20)
at Connection.emit (node:events:390:28)
at Socket.emit (node:events:390:28)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
[2023-08-08T00:06:28.447] [ERROR] pinus-admin - [master-server-1 mqttClient.js] mqtt socket is close, remote server host: 10.65.189.10, port: 3005Error:
通过上面的报错信息,查看了一下代码,代码触发了socket的close和error,然后调了self.onSocketClose();在onSocketClose()方法里面,把this.closed设成了true,然后调了一次reconnect,reconnect里面起了一个定时器去调connect方法,connect方法又把this.closed设成了false,connect不上又触发了socket的close和error,然后一直循环![image](https://github.com/node-pinus/pinus/assets/58498744/22adadeb-690f-48b0-8967-b9b86ddc914b)