python – ZeroMQ在[0.0.0.0:5555]上的Docker上无法使用.bind() – 已经在使用的地址.为什么?

尝试在0.0.0.0:5555地址尝试.bind()时,尝试通过Rancher Cattle在Docker容器中运行它时,ZeroMQ套接字有点问题.

每次我尝试运行它,我都会得到同样的错误:

zmq.error.ZMQError: Address already in use.

试图在我的Dockerfile中做EXPOSE 5555和EXPOSE 5555 / tcp,但它没有帮助我.

这是我的代码的一部分:

...
self.context = zmq.Context()
self.socket = self.context.socket(zmq.PUB)
self.socket.bind('tcp://%s:%d' % ('0.0.0.0', 5555))
...

也许有人有同样的问题.怎么解决?

最佳答案
ZeroMQ API定义了3种方法:

Assigning a local address to a socket

When assigning a local address to a socket using zmq_bind() with the tcp:// transport, the endpoint shall be interpreted as an interface followed by a colon and the TCP port number to use.

An interface may be specified by either of the following:

– The wild-card *, meaning all available interfaces.
– The primary IPv4 address assigned to the interface, in its numeric representation.
– The interface name as defined by the operating system.

Interface names are not standardised in any way and should be assumed to be arbitrary and platform dependent. On Win32 platforms no short interface names exist, thus only the primary IPv4 address may be used to specify an interface.

所以,至少有一个应该让工作进展.

转载注明原文:python – ZeroMQ在[0.0.0.0:5555]上的Docker上无法使用.bind() – 已经在使用的地址.为什么? - 代码日志