Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-2335

thrift incompatibility with py:tornado as server, java as client

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 0.9.1
    • 0.9.3
    • Python - Library
    • None
    • MacOSX 10.7.5
      Python 2.6.7
      Thrift 0.9.1
      Tornado 2.4.1
      Java 1.7.0_17

    Description

      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);

      Attachments

        1. Screenshot 2014-01-29 15.41.28.png
          104 kB
          Anfernee Yongkun Gui

        Activity

          People

            Unassigned Unassigned
            anfernee.gui@gmail.com Anfernee Yongkun Gui
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: