在Mac上的zerorpc python你好世界客户端无法正常工作

时间:2013-06-11 18:07:35

标签: python-2.7 zeromq

我尝试使用这样的zerorpc python客户端:

import zerorpc

c = zerorpc.Client()
c.connect("tcp://127.0.0.1:4242")
print c.hello("RPC")

我在开始时遇到此错误

Traceback (most recent call last):
  File "/Programming/python/snmp01/snmp01.py", line 34, in <module>
    print c.hello("RPC")
  File "/Library/Python/2.7/site-packages/zerorpc-0.4.3-py2.7.egg/zerorpc/core.py", line 256, in <lambda>
    return lambda *args, **kargs: self(method, *args, **kargs)
  File "/Library/Python/2.7/site-packages/zerorpc-0.4.3-py2.7.egg/zerorpc/core.py", line 241, in __call__
    return self._process_response(request_event, bufchan, timeout)
  File "/Library/Python/2.7/site-packages/zerorpc-0.4.3-py2.7.egg/zerorpc/core.py", line 225, in _process_response
    raise
zerorpc.exceptions.RemoteError: Error: Hello, RPC
    at Server._recv.result (//Programming/node/snmp01/node_modules/zerorpc/lib/server.js:146:55)

任何想法?

1 个答案:

答案 0 :(得分:6)

docs目前是错误的。如果节点端没有错误,则需要将null作为第一个参数传递给reply。第一个参数是错误(正如文档中所说的那样。)

我的CoffeeScript代码看起来像这样:

zrpc = require 'zerorpc'
server = new zrpc.Server
  hello: (name, reply) ->
    reply null, "Hello, #{name}!"
server.bind 'tcp://0.0.0.0:4242'