【发布时间】:2015-02-18 08:01:25
【问题描述】:
我尝试了requests,但似乎很慢,因为 tcp 连接需要很长时间(我不知道如何保持套接字打开)
我现在正在尝试zerorpc,它有persistent connection 的概念。
Django node.js 通信适用于第一条消息,但第二次尝试失败并出现Lost remote after 10s heartbeat 错误。
我可能遗漏了一些明显的东西。
# following connection step is done in python a module so that it gets called only one time
import zerorpc
client = zerorpc.Client()
client.connect("tcp://127.0.0.1:7015")
def something(...):
# this gets called for a http request, and we are messaging node.js using the zerorpc client.
...
client.call_rpc(message)
其他客户端(从命令行)仍然可以与服务器对话并获得响应,所以我想这与上面的 django 代码有关。
【问题讨论】:
标签: python django node.js zerorpc