This topic created in 2896 days ago, the information mentioned may be changed or developed.
问题描述:我在腾讯云的服务器上用 python 写了一个 zeromq 的 publisher,监听端口 8099。可我在自己电脑写的 subscriber 却不能连接到服务器,一直收不到服务器 publish 出来的信息。
8099 的端口是开放可用的,我直接开了 python 自带的 CGIHTTPServer 是能连接上去。代码方面也是没有问题的,我在 localhost 环境下测试过才部署的。
希望各位提出想法和建议吧~只要不是水的回复都送铜币
7 replies • 2018-07-04 17:07:57 +08:00
 |
|
1
BingoXuan Jul 4, 2018
贴一下服务器的部分代码
class ZPub(Pub): def __init__(self, identity): super().__init__(identity) ctx = zmq.Context() self.pub_socket = ctx.socket(zmq.PUB) self.pub_socket.setsockopt_string(zmq.IDENTITY, self.identity) self.pub_socket.bind('tcp://127.0.0.1:8099') self.lock = threading.Lock() def _send(self, ts, msg, id_str): self.lock.acquire() self.pub_socket.send_multipart([bytes(m, encoding='ascii') for m in [ts, msg, id_str]]) self.lock.release()
|
 |
|
2
BingoXuan Jul 4, 2018
问题已解决:绑定 tcp://*8099
有谁知道具体原因呢?
|
 |
|
4
xcai Jul 4, 2018 via Android 1
腾讯云安全组放行端口
|
 |
|
5
tempdban Jul 4, 2018 via Android 1
self.pub_socket.bind('tcp://0.0.0.0:8099')
|
 |
|
6
mosliu Jul 4, 2018 1
127.0.0.1 是本机 loopback 网卡吧。。。
|