Communication with Apache Thrift Java-Javascript

I am writing an Apache Thrift-based Java server that will receive data from a Javascript client. I completed the Java server, but the problem is that I can get a working example for the Javascript client (I could not find a good example for it). examples in assembly documentation are not very useful. 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 does not work - because the Java server throws a "Out of Memory" error. I do not know if the error was caused by my client code or Apache Thrift.

What am I doing wrong?

+7
source share
2 answers

Looks like a problematic communication problem. Perhaps you are using a different protocol or transport on the server and client. or an error in the implementation of these protocols. // as an example, I found an error with utf8 characters in sarge-javascript serialization.

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

I hope you can use something from our JS implementation.

0
source

An Out Of Memory error occurs when your server uses TBinaryProtocol , but you try to access it in another way, for example. using a browser (which says HTTP). IMO that is a mistake. Instead, there should be some nice error message.

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

0
source

All Articles