[ 
https://issues.apache.org/jira/browse/THRIFT-2335?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Anfernee Yongkun Gui updated THRIFT-2335:
-----------------------------------------

    Attachment: Screenshot 2014-01-29 15.41.28.png

Left hand side is the python tornado client to python tornado server. Right 
hand side the java client to python tornado server. 

Left hand side has 00 00 00 3d at the beginning, but right hand side doesn't 
have that. 

Here I use binary protocol. 

> 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
>         Attachments: Screenshot 2014-01-29 15.41.28.png
>
>
> 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: 
> TTransport transport = new TSocket("localhost", 50002);
> transport.open();
> TProtocol protocol = new TBinaryProtocol(transport);
> Registry.Client client = new Registry.Client(protocol);
> UnregisterMessage u_message = new UnregisterMessage("1", "2", "3");
> client.unregister_component(u_message);



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to