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?

8
  • Have you tried increasing the JVM memory? Commented Aug 5, 2012 at 21:57
  • Thrift in Java will maliciously throw an OOM on bogus input, it seems that JS client sends something wrong there. I suppose your protocol definition on the server-side has isServerAlive() method? Commented Aug 5, 2012 at 22:02
  • Yes, there is a declaration for isServerAlive() in the Java server implementation. Commented Aug 5, 2012 at 22:04
  • 2
    It seems that JS Thrift library is limited to JSON protocol only, is your server implemented using JSONProtocol? Commented Aug 5, 2012 at 22:07
  • No, How do I implement the server as JSONProtocol? Commented Aug 5, 2012 at 22:10

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.