Zerorpc在recv上抛出错误

时间:2015-10-05 15:53:44

标签: node.js python-2.7 zeromq zerorpc

我在Ubuntu 12.04中使用Python 2.7.3和Node.js 0.10.37并使用zerorpc从节点js调用python ..我的python在端口9004运行,节点客户端侦听9004端口。从Node js调用python中的方法时,我得到以下错误:

ERROR:zerorpc.channel:zerorpc.ChannelMultiplexer ignoring error on recv
Traceback (most recent call last):

File "/usr/local/lib/python2.7/dist-packages/zerorpc/channel.py", line 79, in _channel_dispatcher 
    event = self._events.recv()
File "/usr/local/lib/python2.7/dist-packages/zerorpc/events.py", line 341, in recv      
    event = Event.unpack(get_pyzmq_frame_buffer(blob))
File "/usr/local/lib/python2.7/dist-packages/zerorpc/events.py", line 198, in unpack    
    unpacked_msg = unpacker.unpack()
File "/usr/local/lib/python2.7/dist-packages/msgpack/fallback.py", line 570, in unpack  
    ret = self._fb_unpack(EX_CONSTRUCT, write_bytes)
File "/usr/local/lib/python2.7/dist-packages/msgpack/fallback.py", line 498, in _fb_unpack
    typ, n, obj = self._read_header(execute, write_bytes)
File "/usr/local/lib/python2.7/dist-packages/msgpack/fallback.py", line 347, in _read_header
    b = ord(c)
TypeError: ord() expected string of length 1, but memoryview found

My Node.js客户端代码:

var express = require('express');
var zerorpc = require('zerorpc');
var router = express.Router();

var client = new zerorpc.Client({timeout:30, heartbeatInterval:30000});
client.connect("tcp://0.0.0.0:9004");

router.post('/validateUser/', function(req, res, next){
    var user_name = req.body.user_name;
    client.invoke("validate_user", user_name, function(request, response, more){
        res.send(response);
    });
});

我的Python代码:

import zerorpc
class User():

    def validate_user(self, user_name):
        print user_name

if __name__ == "__main__":
    obj = User()
    s = zerorpc.Server(obj)
    s.bind("tcp://0.0.0.0:9004")
    s.run()

即使是python中的print语句也没有被执行。

我尝试卸载并重新安装zerorpc和zmq。但仍然是同样的错误,相同的代码在具有相同架构的不同Ubuntu机器上工作。

0 个答案:

没有答案