4

我尝试像这样使用 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)

任何想法?

4

1 回答 1

6

文档目前是错误的。如果节点端没有错误,则需要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'
于 2013-08-07T21:30:42.187 回答