错误描述
(pika.adapters.base_connection): 2019-01-05 13:41:46,584 ERROR Error event 25, None
(pika.adapters.base_connection): 2019-01-05 13:41:46,585 CRITICAL Tried to handle an error where no error existed
(pika.adapters.base_connection): 2019-01-05 13:41:46,586 ERROR Socket Error: 104
(pika.adapters.blocking_connection): 2019-01-05 13:41:46,604 ERROR Connection close detected; result=BlockingConnection__OnClosedArgs(connection=<SelectConnection CLOSED socket=None params=<URLParameters host=192.168.0.29 port=5672 virtual_host=/ ssl=False>>, reason_code=-1, reason_text="ConnectionResetError(104, 'Connection reset by peer')")
(log): 2019-01-05 13:41:46,605 INFO ((The AMQP connection was closed (-1) ConnectionResetError(104, 'Connection reset by peer'),), {})
解决方法 转:
https://m.jb51.net/article/152941.htm
def test_main():
s_conn = pika.BlockingConnection(
pika.ConnectionParameters('127.0.0.1',
heartbeat_interval=10,
socket_timeout=5,
credentials=pika.PlainCredentials(USER, PWD)))
heartbeat_interval心跳时间拉长
它是指超过这个时间间隔不发心跳或不给server任何信息,server就会断开连接, 而不是说pika会按这个间隔来发心跳。
模拟断开mq连接
iptables -A OUTPUT -d 192.168.0.142 -p tcp --dport 5672 -j DROP
恢复mq连接
iptables -F
网友评论