8

I'm writing a Java server based on Apache Thrift, that will receive data from a Javascript client. I have completed the Java server, but the problem is that I can get a working example for the Javascript client (I was unable to find a good example for it). the examples in the build documentation aren't very helpful. My current Javascript client is below:

function testServer() {
    try {
        var transport = new Thrift.Transport("http://127.0.0.1:9090");
        var protocol  = new Thrift.Protocol(transport);
        var client = new JavaEventClient(protocol);

        var alive = client.isServerAlive();
    } catch(e) {
    }
}

testServer();  

But the code isn't working - as the Java server throws an "Out Of Memory" Error. I don't know if the error is due to my client code or Apache Thrift.

What am I doing wrong?

JensG
  • 13,148
  • 4
  • 45
  • 55
John
  • 1,699
  • 5
  • 20
  • 29

2 Answers2

0

Looks like problem problem in communications. Maybe you use different protocol or transport on server and client. or bug in implementations of that protocols. // as example I found bug with utf8 characters in thrift-javascript serialization.

Please looks on https://github.com/imysak/using-thrift (My friend and I wrote this simple example of communication Java-Node.js via thrift).

I hope you can use something from our JS implementation.

iMysak
  • 2,170
  • 1
  • 22
  • 35
0

The Out Of Memory error occurs when your server is using TBinaryProtocol but you try to access it in another way, e.g. using a browser (which speaks HTTP). IMO that is a bug. There should be some nice error message instead.

The files how to make a Thrift Java server work with an Thrift Javascript client are scattered throughout the source. I puzzled them together here: https://github.com/LukeOwncloud/ThriftJavaJavascriptDemo

Jack Miller
  • 6,843
  • 3
  • 48
  • 66