Anfernee Yongkun Gui created THRIFT-2335: --------------------------------------------
Summary: thrift incompatibility with py:tornado as server, java as client Key: THRIFT-2335 URL: https://issues.apache.org/jira/browse/THRIFT-2335 Project: Thrift Issue Type: Bug Components: Python - Library Affects Versions: 0.9.1 Environment: MacOSX 10.7.5 Python 2.6.7 Thrift 0.9.1 Tornado 2.4.1 Java 1.7.0_17 Reporter: Anfernee Yongkun Gui Priority: Blocker I used both py:tornado server and client, it worked well. But when I tried to run py:tornado server and java client, it failed with the following error (same thing happens in python client). Starting python server... unregister None ERROR:root:Uncaught exception, closing connection. Traceback (most recent call last): File "/Library/Python/2.6/site-packages/tornado/iostream.py", line 311, in wrapper callback(*args) File "/Library/Python/2.6/site-packages/tornado/stack_context.py", line 229, in wrapped callback(*args, **kwargs) File "/Library/Python/2.6/site-packages/tornado/gen.py", line 383, in inner self.set_result(key, result) File "/Library/Python/2.6/site-packages/tornado/gen.py", line 315, in set_result self.run() File "/Library/Python/2.6/site-packages/tornado/gen.py", line 345, in run yielded = self.gen.send(next) File "/Library/Python/2.6/site-packages/thrift/TTornado.py", line 104, in _readFrameFromStream frame_length, = struct.unpack('!i', frame_header) error: unpack requires a string argument of length 4 My environment is: MacOSX 10.7.5 Python 2.6.7 Thrift 0.9.1 Tornado 2.4.1 Java 1.7.0_17 Thrift file: namespace java protocol namespace py protocol struct RegisterMessage { 1: required string type 2: required string name 3: required string host 4: required i32 port 5: optional i32 service_port } struct UnregisterMessage { 1: required string type 2: required string name 3: required string host } service Registry { bool register_component(1: RegisterMessage message) bool unregister_component(1: UnregisterMessage message) } Python server: class RegistryHandler: def register_component(self, message, callback): print 'register' print message callback(True) def unregister_component(self, message, callback): print 'unregister' print message callback(True) handler = RegistryHandler() processor = gen.protocol.Registry.Processor(handler) pfactory = TBinaryProtocol.TBinaryProtocolFactory() server = TTornado.TTornadoServer(processor, pfactory) print "Starting python server..." server.bind(50002) server.start(1) ioloop.IOLoop.instance().start() print "done!" Java client: public class JavaClient { public static void main(String []args) { try { TTransport transport = new TSocket("localhost", 50002); transport.open(); TProtocol protocol = new TBinaryProtocol(transport); // TProtocol protocol = new TJSONProtocol(transport); Registry.Client client = new Registry.Client(protocol); // RegisterMessage message = new RegisterMessage("1", "2", "3", 4); // client.register_component(message); UnregisterMessage u_message = new UnregisterMessage("1", "2", "3"); client.unregister_component(u_message); } catch (Exception e) { e.printStackTrace(); } } -- This message was sent by Atlassian JIRA (v6.1.5#6160)