找不到协议 socket.getprotobyname
Protocol Not Found socket.getprotobyname
我正在尝试连接到 rabbitMQ 服务器,但它一直无法连接并出现 socket.error: protocol not found
错误。
In [1]: import pika
In [2]: pika.BlockingConnection(pika.ConnectionParameters('ip_of_server'))
错误输出
---------------------------------------------------------------------------
error Traceback (most recent call last)
<ipython-input-2-7adc44418966> in <module>()
----> 1 pika.BlockingConnection(pika.ConnectionParameters('localhost')
2 )
/usr/lib/python2.7/dist-packages/pika/adapters/blocking_connection.pyc in __init__(self, parameters)
105
106 """
--> 107 super(BlockingConnection, self).__init__(parameters, None, False)
108
109 def add_on_close_callback(self, callback_method_unused):
/usr/lib/python2.7/dist-packages/pika/adapters/base_connection.pyc in __init__(self, parameters, on_open_callback, on_open_error_callback, on_close_callback, ioloop, stop_ioloop_on_close)
60 on_open_callback,
61 on_open_error_callback,
---> 62 on_close_callback)
63
64 def add_timeout(self, deadline, callback_method):
/usr/lib/python2.7/dist-packages/pika/connection.pyc in __init__(self, parameters, on_open_callback, on_open_error_callback, on_close_callback)
588 # Initialize the connection state and connect
589 self._init_connection_state()
--> 590 self.connect()
591
592 def add_backpressure_callback(self, callback_method):
/usr/lib/python2.7/dist-packages/pika/adapters/blocking_connection.pyc in connect(self)
204 """
205 self._set_connection_state(self.CONNECTION_INIT)
--> 206 if not self._adapter_connect():
207 raise exceptions.AMQPConnectionError('Could not connect')
208
/usr/lib/python2.7/dist-packages/pika/adapters/blocking_connection.pyc in _adapter_connect(self)
272 # Remove the default behavior for connection errors
273 self.callbacks.remove(0, self.ON_CONNECTION_ERROR)
--> 274 if not super(BlockingConnection, self)._adapter_connect():
275 raise exceptions.AMQPConnectionError(1)
276 self.socket.settimeout(self.SOCKET_CONNECT_TIMEOUT)
/usr/lib/python2.7/dist-packages/pika/adapters/base_connection.pyc in _adapter_connect(self)
103 # Get the addresses for the socket, supporting IPv4 & IPv6
104 sock_addrs = socket.getaddrinfo(self.params.host, self.params.port,
--> 105 0, 0, socket.getprotobyname("tcp"))
106
107 # Iterate through each addr tuple trying to connect
error: protocol not found
我读到这篇文章是因为它在 base_connection.pyc 中的 socket.getprotobyname 行失败了。然后我尝试单独使用 socket.getprotobyname,但我一直在使用 error: protocol not found
。它显然无法正常我的 TCP 连接。
据我所知,它应该输出 6
In [5]: import socket
In [6]: socket.getprotobyname('tcp')
---------------------------------------------------------------------------
error Traceback (most recent call last)
<ipython-input-6-3a85adf1710a> in <module>()
----> 1 socket.getprotobyname('tcp')
error: protocol not found
我正在使用 Ubuntu 14.04 和 python 2.7.6,我不知道如何解决这个错误。
我读过一些关于 /etc/protocols 文件的帖子,但我似乎没有。这可能是问题所在吗?如果是这样,是否有我可以下载的通用文件或创建方法?
是的,您应该有一个 /etc/protocols
文件。它必须以某种方式被删除。它来自 netbase
包。
这应该重新安装它:
sudo apt-get -o Dpkg::Options::="--force-confmiss" install --reinstall netbase
(详情请见 https://askubuntu.com/questions/66533/how-can-i-restore-configuration-files)
我正在尝试连接到 rabbitMQ 服务器,但它一直无法连接并出现 socket.error: protocol not found
错误。
In [1]: import pika
In [2]: pika.BlockingConnection(pika.ConnectionParameters('ip_of_server'))
错误输出
---------------------------------------------------------------------------
error Traceback (most recent call last)
<ipython-input-2-7adc44418966> in <module>()
----> 1 pika.BlockingConnection(pika.ConnectionParameters('localhost')
2 )
/usr/lib/python2.7/dist-packages/pika/adapters/blocking_connection.pyc in __init__(self, parameters)
105
106 """
--> 107 super(BlockingConnection, self).__init__(parameters, None, False)
108
109 def add_on_close_callback(self, callback_method_unused):
/usr/lib/python2.7/dist-packages/pika/adapters/base_connection.pyc in __init__(self, parameters, on_open_callback, on_open_error_callback, on_close_callback, ioloop, stop_ioloop_on_close)
60 on_open_callback,
61 on_open_error_callback,
---> 62 on_close_callback)
63
64 def add_timeout(self, deadline, callback_method):
/usr/lib/python2.7/dist-packages/pika/connection.pyc in __init__(self, parameters, on_open_callback, on_open_error_callback, on_close_callback)
588 # Initialize the connection state and connect
589 self._init_connection_state()
--> 590 self.connect()
591
592 def add_backpressure_callback(self, callback_method):
/usr/lib/python2.7/dist-packages/pika/adapters/blocking_connection.pyc in connect(self)
204 """
205 self._set_connection_state(self.CONNECTION_INIT)
--> 206 if not self._adapter_connect():
207 raise exceptions.AMQPConnectionError('Could not connect')
208
/usr/lib/python2.7/dist-packages/pika/adapters/blocking_connection.pyc in _adapter_connect(self)
272 # Remove the default behavior for connection errors
273 self.callbacks.remove(0, self.ON_CONNECTION_ERROR)
--> 274 if not super(BlockingConnection, self)._adapter_connect():
275 raise exceptions.AMQPConnectionError(1)
276 self.socket.settimeout(self.SOCKET_CONNECT_TIMEOUT)
/usr/lib/python2.7/dist-packages/pika/adapters/base_connection.pyc in _adapter_connect(self)
103 # Get the addresses for the socket, supporting IPv4 & IPv6
104 sock_addrs = socket.getaddrinfo(self.params.host, self.params.port,
--> 105 0, 0, socket.getprotobyname("tcp"))
106
107 # Iterate through each addr tuple trying to connect
error: protocol not found
我读到这篇文章是因为它在 base_connection.pyc 中的 socket.getprotobyname 行失败了。然后我尝试单独使用 socket.getprotobyname,但我一直在使用 error: protocol not found
。它显然无法正常我的 TCP 连接。
据我所知,它应该输出 6
In [5]: import socket
In [6]: socket.getprotobyname('tcp')
---------------------------------------------------------------------------
error Traceback (most recent call last)
<ipython-input-6-3a85adf1710a> in <module>()
----> 1 socket.getprotobyname('tcp')
error: protocol not found
我正在使用 Ubuntu 14.04 和 python 2.7.6,我不知道如何解决这个错误。
我读过一些关于 /etc/protocols 文件的帖子,但我似乎没有。这可能是问题所在吗?如果是这样,是否有我可以下载的通用文件或创建方法?
是的,您应该有一个 /etc/protocols
文件。它必须以某种方式被删除。它来自 netbase
包。
这应该重新安装它:
sudo apt-get -o Dpkg::Options::="--force-confmiss" install --reinstall netbase
(详情请见 https://askubuntu.com/questions/66533/how-can-i-restore-configuration-files)