0
需要一些幫助!使用Rabbit MQ RPC運行python腳本。我得到一個Socket 104
,Socket closed when connection was open
錯誤。下面是python的追溯和一些代碼:Rabbit MQ python腳本。連接打開時套接字關閉
Traceback (most recent call last):
File "./server.py", line 34, in <module>
channel.start_consuming()
File "/usr/lib/python2.6/site-packages/pika/adapters/blocking_connection.py", line 1681, in start_consuming
self.connection.process_data_events(time_limit=None)
File "/usr/lib/python2.6/site-packages/pika/adapters/blocking_connection.py", line 656, in process_data_events
self._dispatch_channel_events()
File "/usr/lib/python2.6/site-packages/pika/adapters/blocking_connection.py", line 469, in _dispatch_channel_events
impl_channel._get_cookie()._dispatch_events()
File "/usr/lib/python2.6/site-packages/pika/adapters/blocking_connection.py", line 1310, in _dispatch_events
evt.body)
File "./server.py", line 30, in on_request
body=json.dumps(DEVICE_INFO))
File "/usr/lib/python2.6/site-packages/pika/adapters/blocking_connection.py", line 1978, in basic_publish
mandatory, immediate)
File "/usr/lib/python2.6/site-packages/pika/adapters/blocking_connection.py", line 2065, in publish
self._flush_output()
File "/usr/lib/python2.6/site-packages/pika/adapters/blocking_connection.py", line 1174, in _flush_output
*waiters)
File "/usr/lib/python2.6/site-packages/pika/adapters/blocking_connection.py", line 395, in _flush_output
raise exceptions.ConnectionClosed()
pika.exceptions.ConnectionClosed
你能幫助我如何設置等待時間嗎?我在我的unix機器上運行我的腳本 –
您使用[rabbitmqctl](https://www.rabbitmq.com/man/rabbitmqctl.1.man.html)嗎?如果是這樣,它應該有無限超時,或者你可以顯式聲明超時?我不確定,但是如果打開或不打開,您可以首先在端口上使用nmap進行檢查。如果它是開放的,那麼問題將會是別的。但是,如果它在得到這個錯誤時關閉,那麼你可以檢查如何讓你的兔子mq服務器保持打開狀態。您還可以使用netcat強制打開端口,然後等待rabbit mq接受請求。 –
您也可以簽出[rabbitmq.config](https://www.rabbitmq.com/configure.html)並增加handshake_timeout環境變量。但是如果您在帖子中包含更多詳細信息會更好,因爲這可以幫助其他人瞭解您的問題。 –