Apache Thrift Java-Javascript通信 [英] Apache Thrift Java-Javascript communication

查看:66
本文介绍了Apache Thrift Java-Javascript通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个基于Apache Thrift的Java服务器,它将从Javascript客户端接收数据。我已经完成了Java服务器,但问题是我可以为Javascript客户端找到一个有效的例子(我无法找到一个很好的例子)。构建文档中的示例不是很有用。我当前的Javascript客户端如下:

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

但代码无效 - 因为Java服务器抛出Out of Memory错误。我不知道错误是由于我的客户端代码还是Apache Thrift。

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.

我做错了什么?

推荐答案

当您的服务器使用 TBinaryProtocol Out of Memory 错误c>但你尝试以另一种方式访问​​它,例如使用浏览器(说HTTP)。 IMO是一个bug。应该有一些很好的错误消息。

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.

如何使Thrift Java服务器与Thrift Javascript客户端一起工作的文件分散在整个源代码中。我在这里一起困惑: https://github.com/LukeOwncloud/ThriftJavaJavascriptDemo

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

这篇关于Apache Thrift Java-Javascript通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆