thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Abernethy <randy.aberne...@gmail.com>
Subject Re: Problems calling thrift server in python from thrift client in javascript
Date Fri, 27 Mar 2015 00:36:15 GMT
Hello Nishant,

It looks like you are using Browser based JavaScript and thrift.js. If so,
at least one problem is that the Python server is using the TBinaryProtocol
and the JavaScript client you have is using TJSONProtocol. Your Javascript
setup above is equivalent to:

      (function() {
        var transport = new Thrift.TXHRTransport("
http://localhost:30303/pythonImpl/pythonServer");
        var protocol  = new Thrift.TJSONProtocol(transport);
        var client    = new HelloWorldClient(protocol);
        ...
      })();

The original thrift.js only supported JSON protocol and that is what you
get when you use Thrift.Protocol. This is really confusing because the
default protocol in almost every other Apache Thrift setting is
TBinaryProtocol. I would recommend avoiding the default transport and
protocol syntax for this reason (it hides the actual implementation chosen).

A browser based binary protocol has been proposed and almost built on
several occasions but the current thinking appears to be targeted at using
the NodeJS JavaScript implementation for all JavaScript environments (using
Browserify for browser implementation). To support the JavaScript client
you have you could change the Python protocol to TJSONProtocol.

Best,
Randy




On Wed, Mar 25, 2015 at 3:34 PM, Nishant Sthalekar <nishant06jun@gmail.com>
wrote:

> Hi all,
>    I am trying to connect to python thrift server from a javacript thrift
> client. Currently I am just using a tutorial code on which I will build
> later. When I connect I get the following error on server.
>
>
> D:\Game Component
> Integration\Project\thriftPyTest\pythonImpl>pythonServer.pyStarting
> python server...
> ERROR:thrift.server.TServer:Traceback (most recent call last):File
> "build\bdist.win32\egg\thrift\server\TServer.py", line 88, in serve
> self.processor.process(iprot, oprot)File
> "../gen-py\helloworld\HelloWorld.py", line 133, in process (name,
> type, seqid) = iprot.readMessageBegin()File
> "build\bdist.win32\egg\thrift\protocol\TBinaryProtocol.py", line 140,
> in readMessageBegin
> name = self.trans.readAll(sz)File
> "build\bdist.win32\egg\thrift\transport\TTransport.py", line 58, in
> readAll
> chunk = self.read(sz - have)File
> "build\bdist.win32\egg\thrift\transport\TTransport.py", line 159, in
> read
> self.__rbuf = StringIO(self.__trans.read(max(sz,
> self.__rbuf_size)))File
> "build\bdist.win32\egg\thrift\transport\TSocket.py", line 105, in read
> buff = self.handle.recv(sz)MemoryError
>
>
> Client code is as follows
>
>   thriftCall:function() {
>
>     var transport = new
> Thrift.Transport("http://localhost:30303/pythonImpl/pythonServer");
>     var protocol  = new Thrift.Protocol(transport);
>     var client    = new HelloWorldClient(protocol);
>
>
>
>     try {
>         result = client.ping();
>         cc.log(result);
>
>         result = client.sayHello();
>         cc.log(result);
>
>         result = client.sayMsg(HELLO_IN_KOREAN);
>         cc.log(result);
>     }catch(ouch){
>         cc.log("Problem!!!");
>     }}
>
>
> and server code can be found on this link
> http://tkang.blogspot.ca/2010/07/thrift-server-client-in-python.html
>
> If I try to connect the server using python client, then it works fine.
> Please help me out with this.
> Thanks
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message