GithubHelp home page GithubHelp logo

facebook / fbthrift Goto Github PK

View Code? Open in Web Editor NEW
2.5K 192.0 599.0 182.07 MB

Facebook's branch of Apache Thrift, including a new C++ server.

License: Apache License 2.0

C++ 55.58% C 0.07% Python 7.43% Emacs Lisp 0.05% Shell 0.04% Thrift 9.80% Go 3.30% Java 9.79% Ruby 0.03% Hack 1.34% CMake 0.66% Rust 1.94% Mustache 6.37% Cython 1.70% JavaScript 0.21% CSS 0.02% Vim Script 0.01% MDX 1.66%

fbthrift's Introduction

Facebook Thrift

Support Ukraine Linux Build Status macOS Build Status Windows Build Status Facebook Thrift Logo

Thrift is a serialization and RPC framework for service communication. Thrift enables these features in all major languages, and there is strong support for C++, Python, Hack, and Java. Most services at Facebook are written using Thrift for RPC, and some storage systems use Thrift for serializing records on disk.

Facebook Thrift is not a distribution of Apache Thrift. This is an evolved internal branch of Thrift that Facebook re-released to open source community in February 2014. Facebook Thrift was originally released closely tracking Apache Thrift but is now evolving in new directions. In particular, the compiler was rewritten from scratch and the new implementation features a fully asynchronous Thrift server. Read more about these improvements in the ThriftServer documentation.

You can also learn more about this project in the original Facebook Code blog post.

Table of Contents

About Thrift

At a high level, Thrift is three major things:

A Code Generator

Thrift has a code generator which generates data structures that can be serialized using Thrift, and client and server stubs for RPC, in different languages.

A Serialization Framework

Thrift has a set of protocols for serialization that may be used in different languages to serialize the generated structures created from the code generator.

An RPC Framework

Thrift has a framework to frame messages to send between clients and servers and to call application-defined functions when receiving messages in different languages.

There are several key goals for these components:

  • Ease of use: Thrift takes care of the boilerplate of serialization and RPC and enables the developer to focus on the schema of the system's serializable types and on the interfaces of the system's RPC services.

  • Cross-language support: Thrift enables intercommunication between different languages. For example, a Python client communicating with a C++ server.

  • Performance: Thrift structures and services enable fast serialization and deserialization, and its RPC protocol and frameworks are designed with performance as a feature.

  • Backwards compatibility: Thrift allows fields to be added to and removed from serializable types in a manner that preserves backward and forward compatibility.

Building

Dependencies

On Linux or MacOS (with Homebrew installed) you can install system dependencies to avoid building them:

# Clone the repo
git clone https://github.com/facebook/fbthrift
# Install dependencies
cd fbthrift
./build/fbcode_builder/getdeps.py install-system-deps --recursive fbthrift

On other platforms or if on Linux and without system dependencies getdeps.py will mostly download and build them for you during the build step.

Some of the dependencies getdeps.py uses and installs are:

System: Boost, CMake, OpenSSLv1.0.2g, PThreads, Python, and Zlib

External: {fmt}, GFlags, GLog, and GTest and GMock

Facebook: Fizz, Folly, Wangle, and Zstd

The Thrift compiler only depends on Boost, CMake and {fmt}.

Build

# Clone the repo
git clone https://github.com/facebook/fbthrift
cd fbthrift
# Build, using system dependencies if available
./build/fbcode_builder/getdeps.py --allow-system-packages build fbthrift

getdeps.py will invoke cmake etc and put output in its scratch area (you can see in logs, and can override with --scratch-path):

  • installed/fbthrift/bin/thrift1: The Thrift compiler binary to generate client and server code.
  • installed/fbthrift/lib/libthriftcpp2.a: Library for clients and servers.

If you want to invoke cmake again to iterate, there is an helpful run_cmake.py output in the scratch build/fbthrift directory.

CMake options:

  • THRIFT_COMPILER_ONLY: specifies whether to build only the Thrift compiler (OFF by default)
  • enable_tests: specifies whether to enable tests

Thrift Files

When using thrift and the CMake build system, include: ThriftLibrary.cmake in your project. This includes the following macro to help building Thrift files:

thrift_library(
  #file_name
  #services
  #language
  #options
  #file_path
  #output_path
)

This generates a library called file_name-<language>. That is, for Test.thrift compiled as cpp2, it will generate the library Test-cpp2. This should be added as a dependency to any source or header file that contains an include to generated code.

C++ Static Reflection

Information regarding C++ Static Reflection support can be found under the static reflection library directory, in the corresponding README file.

C++ Server Metrics

To collect runtime stats from a Thrift server, e.g. the number of active requests/connections, the C++ Thrift server supports an observer API that installs callbacks at a set of specific execution points in the server.

To expose collected metrics out of the server process, one way is to use fb303 interfaces, see fb303 Github repo.

License

Facebook Thrift is Apache 2.0 licensed.

fbthrift's People

Contributors

ahilger avatar ahornby avatar alandau avatar ami7o avatar andriigrynenko avatar avalonalex avatar chadaustin avatar clairezhang-fb avatar ddrcoder avatar dusty-phillips avatar echistyakov avatar eduardo-elizondo avatar filip-f avatar fried avatar iahs avatar jmswen avatar junzh0u avatar mizuchi avatar mshneer avatar orvid avatar praihan avatar rmakheja avatar simpkins avatar spalamarchuk avatar stevegury avatar thedavekwon avatar vitaut avatar wez avatar yfeldblum avatar zhxchen17 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fbthrift's Issues

CPP2 Out of order responses with THeader "not" working

Hi,

I have been trying for a while to get out of order responses to work with THeader protocol using cpp2::ThriftServer and a cpp2 client. I created an echo server deriving from cpp2::ThriftServer which uses THeaderProtocolFactory and THeaderTransportFactory by manually setting them.

Then I fired up a cpp2 client to send requests to the server and the server echoes back the requests. The client uses the HeaderClientChannel::newChannel. When I use the sync method of the client within a single thread, everything works fine. However, the moment I use the async method, it breaks down. I created a separate client worker thread with an eventbase to which my TAsyncSocket is attached. I am running the following in my main thread. The evb is the eventbase associated with the client worker thread.

for (int i = 0; i < 1000; i++) {
evb->runInEventBaseThread(&{
client.ping(unique_ptr(new Callback(i)), to_string(i));
});
}

I am getting garbled up responses and eventually get a core dump stating that at some point the event base was accessed by a thread which should not touch the event base. I would highly appreciate if you guys could point out where I am configuring my client incorrectly. Any examples on how to use a cpp2 server + cpp2 client with out of order responses would be highly appreciated. Otherwise, we need to implement a socket pool etc.

Unable to link against libressl / boringssl - get_cipher_by_char usage

While compiling hhvm with a linux system that uses libressl I noted that I get errors like:

In file included from /root/tmp/hhvm/third-party/proxygen/lib/ssl/SSLUtil.h:14:0,
from /root/tmp/hhvm/third-party/proxygen/lib/services/ServerSocketConfig.h:14,
from /root/tmp/hhvm/third-party/proxygen/lib/services/Acceptor.h:14,
from /root/tmp/hhvm/third-party/proxygen/lib/services/Acceptor.cpp:10:
/root/tmp/hhvm/third-party/thrift/thrift/lib/cpp/async/TAsyncSSLSocket.h: In member function 'void apache::thrift::async::TAsyncSSLSocket::getSSLClientCiphers(std::string&)':
/root/tmp/hhvm/third-party/thrift/thrift/lib/cpp/async/TAsyncSSLSocket.h:558:29: error: 'const SSL_METHOD' has no member named 'get_cipher_by_char'
TLSv1_2_method()->get_cipher_by_char((unsigned char*)&cipherCode);

get_cipher_by_char seems to have been removed in non-openssl openssl's because it's unnecessary with sslv2/v3 removed.

It would be nice if hhvm supported being built against libressl too.

Cheers,
Michael

Cpp2RequestContext::getHeader() is changed to protected which cause gen-cpp2/SaslAuthService.cpp won't compile

in cpp2 dir, make the cpp2 library:

In file included from ../../../thrift/lib/cpp2/async/AsyncProcessor.h:29:0,
from ../../../thrift/lib/cpp2/ServiceIncludes.h:8,
from gen-cpp2/SaslAuthService.h:9,
from gen-cpp2/SaslAuthService.cpp:7:
../../../thrift/lib/cpp2/server/Cpp2ConnContext.h: In member function ‘apache::thrift::concurrency::PriorityThreadManager::PRIORITY apache::thrift::sasl::SaslAuthServiceSvIf::getprio_authFirstRequest(apache::thrift::Cpp2RequestContext_)’:
../../../thrift/lib/cpp2/server/Cpp2ConnContext.h:228:47: error: ‘virtual apache::thrift::transport::THeader_ apache::thrift::Cpp2RequestContext::getHeader()’ is protected
virtual apache::thrift::transport::THeader* getHeader() {
^
gen-cpp2/SaslAuthService.cpp:18:67: error: within this context
apache::thrift::concurrency::PRIORITY prio0 = reqCtx->getHeader()->getCallPriority();
^
In file included from ../../../thrift/lib/cpp2/async/AsyncProcessor.h:29:0,
from ../../../thrift/lib/cpp2/ServiceIncludes.h:8,
from gen-cpp2/SaslAuthService.h:9,
from gen-cpp2/SaslAuthService.cpp:7:
../../../thrift/lib/cpp2/server/Cpp2ConnContext.h: In member function ‘apache::thrift::concurrency::PriorityThreadManager::PRIORITY apache::thrift::sasl::SaslAuthServiceSvIf::getprio_authNextRequest(apache::thrift::Cpp2RequestContext_)’:
../../../thrift/lib/cpp2/server/Cpp2ConnContext.h:228:47: error: ‘virtual apache::thrift::transport::THeader_ apache::thrift::Cpp2RequestContext::getHeader()’ is protected
virtual apache::thrift::transport::THeader* getHeader() {
^
gen-cpp2/SaslAuthService.cpp:47:67: error: within this context
apache::thrift::concurrency::PRIORITY prio1 = reqCtx->getHeader()->getCallPriority();

Maybe a bug in NumaThreadManager

Hi guy,

I use threadmanager of NumaThreadManager, I just dynamic add workers and remove it.
but after remove sometimes, the server not response anything.

I look into the code, maybe the follow code need some judgement.

void NumaThreadManager::removeWorker(size_t t) {
for (size_t i = 0; i < t; i++) {
managers_[workerNode_-- % managers_.size()]->removeWorker(1);
}
}

porting to Java

Hi

Do you know if anyone's currently working on implementing a fully asynchronous server (similar to fbthrift cpp2) in Java? Or an efficient implementation of IOBuf in Java?

cannot stat '.libs/libthrift.lai'

I have a thrift1 binary correctly installed via

make -j6

I have libthriftcpp2.{so,a}
I have libthrift{.so,a}

When trying to do a

make install

it cannot stat '.libs/libthrift.lai'

Here is the full output of

$ make install >> log.txt 2>&1   #sorry github didn't allow me to attach the log file. 

https://gist.github.com/d4b9c26b165a37bca0e4
 [agallego@bolt] ~/.bolt/fbthrift-41f7445 
$ find . -type f  | grep .la$
./thrift/tutorial/scala/server/server.scala
./thrift/tutorial/scala/client/client.scala
./thrift/compiler/libparse.la
./thrift/compiler/py/frontend.la
./thrift/compiler/libthriftcompilerbase.la
./thrift/lib/cpp2/libthriftcpp2.la
./thrift/lib/cpp/libthriftz.la
./thrift/lib/cpp/libthrift.la

[agallego@bolt] ~/.bolt/fbthrift-41f7445 
$ grep -R "*.lai" .


PHP library does not have THeaderProtocol defined

Hi

This is not a bug at all more a feature/roadmap request.

The new changes to CPP and generator here are very welcome and mirror several features I am on the verge of hacking into thrift myself (specifically augmenting RPC protocol with headers and variable encoding and a more flexible generator) so I'd love to use your implementation rather than another custom fork.

I'm not very clear from the release notes and reading code though what state the non-cpp language bindings are in here.

Specifically my case needs PHP to work and given that some changes have been made to both generated PHP and the lib compared to Apache thrift, it seems like none of the new features (particularly THeaderProtocol and out-of-order messaging) were built for PHP yet. I was reasonably surprised by that given Facebook's use of PHP for front end especially since python does appear to have the new protocol.

Is this because there are internal different versions/libraries used by your PHP code (like built into the internal version of HHVM or something) or do you really not have a need for any of the new features in PHP client RPCs?

Are there plans to work on that at any point?

Thanks for your commitment to Open Source and the great software!

Paul

can't build, some dependencies don't get found

while running deps.sh I get the following issues. The files do exist, not sure why they're not getting found

...
checking double-conversion/double-conversion.h usability... no
checking double-conversion/double-conversion.h presence... no
checking for double-conversion/double-conversion.h... no
configure: error: Couldn't find double-conversion.h, please download from http://code.google.com/p/double-conversion/
make: *** No targets specified and no makefile found. Stop.

...

checking folly/String.h usability... no
checking folly/String.h presence... no
checking for folly/String.h... no
configure: error: Please install folly

configure error while finding folly

checking folly/String.h usability... no
checking folly/String.h presence... no
checking for folly/String.h... no
configure: error: Please install folly

I tried install folly into my own dir and /usr/local/ , it could not found folly
Tired link /usr/local/include/folly to /usr/inlcude, it also could not folly.

I'm not using Ubuntu.

Question: Send responses out of order?

Hi

By saying "send responses out of order", do you mean sending responses to a client using a SINGLE connection and issuing multiple async requests one after another? or a client using multiple connections?

Can I check the connection status every few seconds?

I used the server->setServerEventHandler to add an event handler.When a client connected, I will bind some vars to the connection(use the ctx->setUserData), Then I use "eb->runAfterDelay" function to do some work after few seconds, I will use ctx->getUserData to get the vars I added before.

This is my test code:

#include <thrift/lib/cpp2/server/ThriftServer.h>
#include "ThriftTest.h"

using namespace apache::thrift;
using namespace apache::thrift::server;
using namespace apache::thrift::async;
using namespace apache::thrift::transport;
using namespace apache::thrift::test::cpp2;

struct SomeStruct {

};

class TestServerEventHandler
    : public server::TServerEventHandler
    , public TProcessorEventHandler
    , public TProcessorEventHandlerFactory
    , public std::enable_shared_from_this<TestServerEventHandler> {

public:
    std::shared_ptr<TProcessorEventHandler> getEventHandler() {
        return shared_from_this();
    }

    void newConnection(TConnectionContext* ctx) {
        // add some vars to the ctx
        SomeStruct* s = new SomeStruct();
        ctx->setUserData(s);

        Cpp2ConnContext* cpp2ctx = dynamic_cast<Cpp2ConnContext*>(ctx);
        ThriftTestAsyncClient* client = cpp2ctx->getDuplexClient<ThriftTestAsyncClient>();
        TEventBase* eb = client->getChannel()->getEventBase();

        eb->runAfterDelay([ctx]() mutable {
            void* p = ctx->getUserData();
            if (p) {
                std::cout << "do some work here..." << std::endl;
            } else {
                std::cout << "maybe the client is close" << std::endl;
            }
        }, 10000);
    }

};

class ThriftTestInterface : public ThriftTestSvIf {

};

int main(int argc, char* argv[]) {
    auto server = std::make_shared<ThriftServer>();
    server->setPort(8888);
    server->setInterface(std::unique_ptr<ThriftTestInterface>(new ThriftTestInterface));
    server->setDuplex(true);

    std::shared_ptr<TestServerEventHandler> handler = std::make_shared<TestServerEventHandler>();
    server->setServerEventHandler(handler);

    server->serve();
    return 0;
}

My question is :

If a client connected to my server(I used "telnet localhost 8888" for a test), and then close the connection immediately (maybe CTRL+C). After 10s, I will use "void* p = ctx->getUserData();" to get my vars from a closed ctx, p is nullptr, so it printed "maybe the client is close". The code can work, and no crash. But, if I use the "valgrind" tool to do a memcheck, It will report :

==23976== Invalid read of size 8
==23976==    at 0x49F7B9: TestServerEventHandler::newConnection(apache::thrift::server::TConnectionContext*)::{lambda()#1}::operator()() (t.cpp:35)
==23976==    by 0x4A114A: std::_Function_handler<void (), TestServerEventHandler::newConnection(apache::thrift::server::TConnectionContext*)::{lambda()#1}>::_M_invoke(std::_Any_data const&) (functional:2071)
==23976==    by 0x4B1007: std::function<void ()>::operator()() const (functional:2464)
==23976==    by 0x5DFF128: folly::EventBase::CobTimeout::timeoutExpired() (EventBase.cpp:114)
==23976==    by 0x5DFB3FB: folly::AsyncTimeout::libeventCallback(int, short, void*) (AsyncTimeout.cpp:151)
==23976==    by 0x8D7FA3B: event_process_active_single_queue (event.c:1340)
==23976==    by 0x8D7FA3B: event_process_active (event.c:1407)
==23976==    by 0x8D7FA3B: event_base_loop (event.c:1604)
==23976==    by 0x5DFFEFD: folly::EventBase::loopBody(int) (EventBase.cpp:277)
==23976==    by 0x5E00E99: folly::EventBase::loopForever() (EventBase.cpp:366)
==23976==    by 0x64DEC47: apache::thrift::Cpp2Worker::serve() (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x64DFD2C: apache::thrift::server::TServer::run() (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x655FE78: apache::thrift::concurrency::NumaRunnable::run() (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x5B2300A: apache::thrift::concurrency::PthreadThread::threadMain(void*) (in /usr/local/lib/libthrift.so.7.0.0)
==23976==  Address 0xe66da78 is 120 bytes inside a block of size 336 free'd
==23976==    at 0x4C270B1: operator delete(void*) (vg_replace_malloc.c:507)
==23976==    by 0x64D279F: apache::thrift::Cpp2Connection::~Cpp2Connection() (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x64E3047: std::_Sp_counted_ptr<apache::thrift::Cpp2Connection*, (__gnu_cxx::_Lock_policy)2>::_M_dispose() (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x4A0805: std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (shared_ptr_base.h:144)
==23976==    by 0x49FA68: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() (shared_ptr_base.h:546)
==23976==    by 0x64D706B: std::__shared_ptr<apache::thrift::Cpp2Connection, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x64D7085: std::shared_ptr<apache::thrift::Cpp2Connection>::~shared_ptr() (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x64D4546: apache::thrift::Cpp2Connection::channelClosed(folly::exception_wrapper&&)::{lambda()#1}::operator()() const (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x64D54FF: folly::ScopeGuardImpl<apache::thrift::Cpp2Connection::channelClosed(folly::exception_wrapper&&)::{lambda()#1}>::execute() (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x64D543B: folly::ScopeGuardImpl<apache::thrift::Cpp2Connection::channelClosed(folly::exception_wrapper&&)::{lambda()#1}>::~ScopeGuardImpl() (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x64D474B: apache::thrift::Cpp2Connection::channelClosed(folly::exception_wrapper&&) (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x64C7D3A: apache::thrift::HeaderServerChannel::messageChannelEOF() (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==
==23976== Invalid read of size 8
==23976==    at 0x49E5A8: apache::thrift::server::TConnectionContext::getUserData() const (TConnectionContext.h:98)
==23976==    by 0x49F7CE: TestServerEventHandler::newConnection(apache::thrift::server::TConnectionContext*)::{lambda()#1}::operator()() (t.cpp:35)
==23976==    by 0x4A114A: std::_Function_handler<void (), TestServerEventHandler::newConnection(apache::thrift::server::TConnectionContext*)::{lambda()#1}>::_M_invoke(std::_Any_data const&) (functional:2071)
==23976==    by 0x4B1007: std::function<void ()>::operator()() const (functional:2464)
==23976==    by 0x5DFF128: folly::EventBase::CobTimeout::timeoutExpired() (EventBase.cpp:114)
==23976==    by 0x5DFB3FB: folly::AsyncTimeout::libeventCallback(int, short, void*) (AsyncTimeout.cpp:151)
==23976==    by 0x8D7FA3B: event_process_active_single_queue (event.c:1340)
==23976==    by 0x8D7FA3B: event_process_active (event.c:1407)
==23976==    by 0x8D7FA3B: event_base_loop (event.c:1604)
==23976==    by 0x5DFFEFD: folly::EventBase::loopBody(int) (EventBase.cpp:277)
==23976==    by 0x5E00E99: folly::EventBase::loopForever() (EventBase.cpp:366)
==23976==    by 0x64DEC47: apache::thrift::Cpp2Worker::serve() (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x64DFD2C: apache::thrift::server::TServer::run() (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x655FE78: apache::thrift::concurrency::NumaRunnable::run() (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==  Address 0xe66da80 is 128 bytes inside a block of size 336 free'd
==23976==    at 0x4C270B1: operator delete(void*) (vg_replace_malloc.c:507)
==23976==    by 0x64D279F: apache::thrift::Cpp2Connection::~Cpp2Connection() (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x64E3047: std::_Sp_counted_ptr<apache::thrift::Cpp2Connection*, (__gnu_cxx::_Lock_policy)2>::_M_dispose() (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x4A0805: std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (shared_ptr_base.h:144)
==23976==    by 0x49FA68: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() (shared_ptr_base.h:546)
==23976==    by 0x64D706B: std::__shared_ptr<apache::thrift::Cpp2Connection, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x64D7085: std::shared_ptr<apache::thrift::Cpp2Connection>::~shared_ptr() (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x64D4546: apache::thrift::Cpp2Connection::channelClosed(folly::exception_wrapper&&)::{lambda()#1}::operator()() const (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x64D54FF: folly::ScopeGuardImpl<apache::thrift::Cpp2Connection::channelClosed(folly::exception_wrapper&&)::{lambda()#1}>::execute() (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x64D543B: folly::ScopeGuardImpl<apache::thrift::Cpp2Connection::channelClosed(folly::exception_wrapper&&)::{lambda()#1}>::~ScopeGuardImpl() (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x64D474B: apache::thrift::Cpp2Connection::channelClosed(folly::exception_wrapper&&) (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==    by 0x64C7D3A: apache::thrift::HeaderServerChannel::messageChannelEOF() (in /usr/local/lib/libthriftcpp2.so.7.0.0)
==23976==

It says that "Invalid read of size".
So I'm not sure is it safe? I just read a null pointer, and no write to it.
Or suggest me a better way?

Thanks a lot!

Build fails due to no rule to make target libparse.la

In the directory compiler/py
make[4]: *** No rule to make target ../libparse.la', needed bylibfrontend.la'. Stop.

If the dependency on libparse is removed, it fails due to
make[4]: *** No rule to make target ../libthriftcompilerbase.la', needed bylibfrontend.la'. Stop.

If that dependency is also removed, it fails due to
/usr/bin/python setup.py build
Traceback (most recent call last):
File "setup.py", line 39, in
run_setup()
File "setup.py", line 11, in run_setup
shutil.copy('.libs/libfrontend.so.0.0.0', 'frontend.so')
File "/usr/lib64/python2.6/shutil.py", line 84, in copy
copyfile(src, dst)
File "/usr/lib64/python2.6/shutil.py", line 50, in copyfile
with open(src, 'rb') as fsrc:
IOError: [Errno 2] No such file or directory: '.libs/libfrontend.so.0.0.0'

When AX_BOOST_PYTHON fails, it sets BOOST_PYTHON_LIB="" which doesn't work

Make stop beacuse it found a -l
The line is

make[4]: Entering directory `/xxx/proxygen/proxygen/fbthrift/thrift/compiler/py'
/bin/sh ../../libtool --tag=CXX --mode=link g++ -std=gnu++0x -module -avoid-version -no-undefined -l -L/usr/lib64 -lpython2.7 -L/mnt/neuhome/home/roy/sorgenti/proxygen/proxygen/fbthrift/thrift/folly/folly/.libs/ -o frontend.la -rpath /usr/local/lib64 frontend_la-compiler.lo ../libparse.la ../libthriftcompilerbase.la -lssl -lcrypto -lrt -lpthread -lsasl2 -lfolly -lnuma -lsnappy -lgflags -lglog

I've removed the -l and executed by hand the command and is ok, I've tried to search where the problem is but nothing.

Missing libnuma-dev in dependencies

Hi,

I've compiled fbthrift on a fresh Ubuntu 14.04 machine, installed all dependencies listed and ran deps.sh (without manually installing folly before). I then get a configure error about numa library being missing. apt-get install libnuma-dev solved it.

dep.sh is broken

I have trouble building fbthrift by using deps.sh. Folly is at v15.0 but when I run deps.sh it looks for Folly 13. I had to manually build Folly and symlink the .so file as v13 for the build to succeed.

sync client hang forever if the channel is not good()

Looks like the autogenerated code calls loopForever() expecting the callback to call terminateLoopSoon(). The issue is that the callback may be invoked before we call loopForever() (example - the channel is already closed).

TAsyncSocket destruction outside EventBase Thread

I am writing an application which maintains a pool of client threads and each thread has a bunch of associated sockets. These sockets are periodically refreshed based on a config file which is edited manually - the file contains the host:port information. A thread is responsible for reading the file and refreshing the sockets. The sockets are kept as shared_ptr<> objects and the application the gets shared_ptr - the sockets are destroyed when the shared_ptr ref count goes to zero which may happen in a thread that is outside of the EventBase thread. It seems like this could cause an issue because the destructor would get called by a thread outside of the EventBase thread. Is there a way to resolve this issue ?

fb303?

It seems that fb303 cannot be found in this project?

C++11 move semantics don't work for Thrift types

I tried to do:

thriftObj1 = move(thriftObj2);

It seems to complain saying the the overloaded move() function is ambiguous. Is there a work around for this - do we need to use swap instead ? Otherwise manipulating complex thrift objects becomes quite painful.

Error Linking against libthriftcpp2

Error:

  1. Cannot compile against libthriftcpp2.
  2. Documentation docs/Cpp2.md is incorrect

Missing async_method, instead either 2 methods are generated async_eb_method or async_tm_method

Description:

python -mthrift_compiler.main --strict -v --gen cpp2 IDL.thrift

generates proper classes: e.g.:

 ‘lib/gen-cpp2/MutableEphemeralStateService.h’
 ‘lib/gen-cpp2/MutableEphemeralStateService.tcc’
 ‘lib/gen-cpp2/MutableEphemeralStateService.cpp’

I guess it's just that the documentation is incorrect , see line 16,17

     1      def _generate_service_server_interface_async(self, service, s):
     2          classname = service.name + "SvAsyncIf"
     3          class_signature = "class " + classname
     4          with s.cls(class_signature):
     5              out().label('public:')
     6              out().defn('~{0}()'.format(classname), name=classname,
     7                     modifiers='virtual',
     8                     in_header=True).scope.empty()
     9              for function in service.functions:
    10                  out().defn(self._get_process_function_signature_async(service,
    11                                                                    function),
    12                         name=self._get_async_func_name(function),
    13                         modifiers='virtual',
    14                         pure_virtual=True)
    15  
    16                  # TODO: Remove this once everything has migrated to async_eb or
    17                  # async_tm
    18                  out().defn(self._get_process_function_signature_async(service,
    19                                                                    function),
    20                         name="async_" + function.name,
    21                         modifiers='virtual',
    22                         delete=True)
    23                  if self.flag_future:
    24                      out().defn(self._get_process_function_signature_future(
    25                              service, function),
    26                             name="future_" + function.name,
    27                             modifiers='virtual',
    28                             pure_virtual=True)

Also see this function in teh t_generator.py

    def _get_async_func_name(self, function):
        if self._is_processed_in_eb(function):
            return 'async_eb_' + function.name
        else:
            return 'async_tm_' + function.name

Error I'm trying to debug:

lib/my_library.so: undefined reference to `unsigned int bolt::thrift::cpp2::ClusterConfig::read<apache::thrift::protocol::TProtocol>(apache::thrift::protocol::TProtocol*)'

It would seem as though I needed to link against libthriftcpp2 but it's definitely included as part of my linker flags

e.g.:

ccache g++-4.9 -o build/debug/program_thing build/debug/bolt/program_thing.o -Llib -L/usr/lib -L/usr/local/lib -L/usr/lib/gcc/x86_64-linux-gnu/4.9 -lbolt -lrocksdb -lgflags -lboost_context -lboost_coroutine -lboost_system -lboost_program_options -lboost_filesystem -lboost_date_time -levent -lthriftz -lthrift -lthriftcpp2 -lfolly -lmesos -lcityhash -lglog -lz -lbz2 -llz4 -llzma -lsnappy -lnuma -ldouble-conversion -lkrb5 -lsasl2 -lssl -ljemalloc -lpthread

Any suggestion would be greatly appreciated. I think the bug still stands for at least the documentation

Wrong check for libevent

I'm getting the error
...
checking for libevent >= 1.0... no
configure: error: Please install libevent

The code used to check the libevent version is https://gist.github.com/RoyBellingan/42d1cd5a974e64ce3367
(of course the stdio and the printf are mine, I've also hardcoded the min requested version)
This is around line 18070 in configure (another check is around 19888)
The first check is failed (and secondo seems to pass or is not executed) but the version is 2.0.21-stable

build failed

I just clone the fbthrift, and runs ./deps.sh in thrift/
and get the following error (it does seems THttpParser is not included in any Makefile.am):

libtool: link: g++ -std=gnu++0x -o .libs/ThriftServerTest ThriftServerTest-ThriftServerTest.o /home/byzhang/src/fbthrift/thrift/folly/folly/test/.libs//libgtest.so -L/home/byzhang/src/fbthrift/thrift/folly/folly/test/.libs/ -L/home/byzhang/src/fbthrift/thrift/folly/folly/.libs/ -L/home/byzhang/src/fbthrift/thrift/folly/folly/double-conversion/ ../.libs/libthriftcpp2.so ../libsaslstubs.a libService.a ../../cpp/.libs/libthrift.so -levent -lkrb5 -lsnappy /home/byzhang/src/fbthrift/thrift/folly/folly/.libs//libfolly.so -lgssapi_krb5 -lboost_thread -lssl -lcrypto -lrt -lpthread -lsasl2 -lgflags -lglog
../.libs/libthriftcpp2.so: undefined reference to apache::thrift::util::THttpParser::~THttpParser()' ../.libs/libthriftcpp2.so: undefined reference toapache::thrift::util::THttpParser::THttpParser()'
../.libs/libthriftcpp2.so: undefined reference to apache::thrift::util::THttpParser::getReadBuffer(void**, unsigned long*)' ../.libs/libthriftcpp2.so: undefined reference tovtable for apache::thrift::util::THttpClientParser'
../.libs/libthriftcpp2.so: undefined reference to `apache::thrift::util::THttpParser::readDataAvailable(unsigned long)'

<thrift/lib/cpp/util/ThriftSerializer.h> not exported. How do you suggest printing json

I wrote something similar to this:

// TODO(dreiss): Move part of ThriftJSONString into a .cpp file and remove this.
#include <thrift/lib/cpp/transport/TBufferTransports.h>

/*namespace apache { namespace thrift {

template<typename ThriftStruct>
  std::string ThriftJSONString(const ThriftStruct& ts) {
  using namespace apache::thrift::transport;
  using namespace apache::thrift::protocol;
  TMemoryBuffer* buffer = new TMemoryBuffer;
  std::shared_ptr<TTransport> trans(buffer);
  TJSONProtocol protocol(trans);

  ts.write(&protocol);

  uint8_t* buf;
  uint32_t size;
  buffer->getBuffer(&buf, &size);
  return std::string((char*)buf, (unsigned int)size);
}

}} // apache::thrift
*/

and then i found out that there are already serializers written for this. in ThriftSerializer.h

I checked the installed headers in /usr/local/include/thrift/lib/cpp/util/...

  /usr/local/include/thrift/lib/cpp/util:
  total used in directory 36 available 355810980
  drwxr-xr-x  3 root root 4096 Nov  5 02:56 .
  drwxr-xr-x 11 root root 4096 Dec  7 23:08 ..
  -rw-r--r--  1 root root 2131 Nov  5 02:56 BitwiseCast.h
  drwxr-xr-x  2 root root 4096 Nov  5 02:56 kerberos
  -rw-r--r--  1 root root 2720 Nov  5 02:56 ScopedServerThread.h
  -rw-r--r--  1 root root 2961 Nov  5 02:56 shared_ptr_util.h
  -rw-r--r--  1 root root 4000 Nov  5 02:56 THttpParser.h
  -rw-r--r--  1 root root 2415 Nov  5 02:56 VarintUtils.h
  -rw-r--r--  1 root root 2333 Nov  5 02:56 VarintUtils.tcc


Any suggestions on how to json-ify thrift structs - for debugging.

Cannot compile under Slackware64

Trying to compile under slackware64 14.1 i get:

../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-slackware-linux/4.8.2/../../../../x86_64-slackware-linux/lib -L/usr/lib64/gcc/x86_64-slackware-linux/4.8.2/../../.. /usr/lib64/../lib64/libstdc++.so -lm -lc -lgcc_s /usr/lib64/gcc/x86_64-slackware-linux/4.8.2/crtendS.o /usr/lib64/gcc/x86_64-slackware-linux/4.8.2/../../../../lib64/crtn.o -pthread -Wl,-soname -Wl,frontend.so -o .libs/frontend.so
../.libs/libparse.a(libparse_la-thriftl.o):(.data+0x4): multiple definition of y_field_val' ../.libs/libparse.a(libparse_la-thrifty.o):(.data+0x0): first defined here ../.libs/libparse.a(libparse_la-thriftl.o):(.data+0x8): multiple definition ofy_enum_val'
../.libs/libparse.a(libparse_la-thrifty.o):(.data+0x4): first defined here
../.libs/libparse.a(libparse_la-thriftl.o):(.bss+0x2028): multiple definition of g_arglist' ../.libs/libparse.a(libparse_la-thrifty.o):(.bss+0x0): first defined here ../.libs/libparse.a(libparse_la-thriftl.o):(.bss+0x202c): multiple definition ofyychar'
../.libs/libparse.a(libparse_la-thrifty.o):(.bss+0x4): first defined here
../.libs/libparse.a(libparse_la-thriftl.o):(.bss+0x2030): multiple definition of yylval' ../.libs/libparse.a(libparse_la-thrifty.o):(.bss+0x10): first defined here ../.libs/libparse.a(libparse_la-thriftl.o):(.bss+0x2040): multiple definition ofyynerrs'
../.libs/libparse.a(libparse_la-thrifty.o):(.bss+0x20): first defined here
../.libs/libparse.a(libparse_la-thriftl.o): In function yyparse()': thriftl.cc:(.text+0x24): multiple definition ofyyparse()'
../.libs/libparse.a(libparse_la-thrifty.o):thrifty.cc:(.text+0x24): first defined here
collect2: error: ld returned 1 exit status
make[4]: *** [frontend.la] Error 1
make[4]: se sale del directorio /usr/src/build/fbthrift/thrift/compiler/py' make[3]: *** [all-recursive] Error 1 make[3]: se sale del directorio/usr/src/build/fbthrift/thrift/compiler'
make[2]: *** [all] Error 2
make[2]: se sale del directorio /usr/src/build/fbthrift/thrift/compiler' make[1]: *** [all-recursive] Error 1 make[1]: se sale del directorio/usr/src/build/fbthrift/thrift'
make: *** [all] Error 2

Avoiding namespace cpp2?

I'm currently migrating some code to from using the cpp generator to using the cpp2 generator. As a result I'm having to update a number of my using clauses to include the cpp2 namespace. Is there any way for the generator to not add the cpp2 namespace?

Make fbthrift coexist with thrift

I am trying to pack fbthrift (and some other FB projects that need fbthrift). And now I am trying to understand the project structure.

One of the problems that I met is that it is not possible to install fbthrift along with thrift itself. Following files are conflicting if I run 'make install':

fbthrift-git: /usr/lib/libthrift.so exists in filesystem
fbthrift-git: /usr/lib/libthriftz.so exists in filesystem
fbthrift-git: /usr/lib/pkgconfig/thrift-z.pc exists in filesystem
fbthrift-git: /usr/lib/pkgconfig/thrift.pc exists in filesystem

Should the libraries be renamed to libfbthrift.so instead? This will make possible to install these 2 packages together.

The binary with name 'thrift1' also looks weird. I suggest to rename it to fbthrift.

HandlerCallback exception() runs outside EventBase

We tried to run callback->exception using the HandlerCallback inside a CPP2 ThriftServer using the async_tm callbacks and when we run the exception() call, it fails saying that "not running in eventbase thread". It appears while the callback->result() call does the right thing in terms of switching to the EVB thread, the callback->exception() call does not.

About the gen-cpp folder?

In the previous versions of the thrift compiler, there are options to control if a gen-* folder will be created or not for the generated files.

-o dir Set the output directory for gen-* packages
(default: current directory)
-out dir Set the ouput location for generated files.
(no gen-* folder will be created)

But it seems that this fbthrift compiler doesn't support the '-out dir' (no gen-* folder) option?

This project needs a 1.0 tag or some tag and a reference tag to the folly library

I'm using folly at version

folly-acc5458/

and fbthrift at version:

fbthrift-41f7445/

It took me a while to figure out why the SocketAddress.h wasn't in folly. Basically when I downloaded folly and configured it, then downloaded fbthrift and configured it the project had moved forward in the transitive dependency. Meaning, Folly needed to be ahead to work w/ the version i downloaded from fbthrift.

This project would greatly benefit from a git tag.

I'll be happy to tag both repo's and push upstream. Let me know.

Memory leak when using CloseCallback for HeaderClientChannel

Class HeaderClientChannel has a method to set CloseCallback when connection closed, which requires a naked pointer. The callback will be called in asynchronously. By normal thought, in this case, for an asynchronous callback object, developer will new a callback object, then pass the naked pointer to then function, and hope class HeaderClientChannel take the ownership, and free the callback object if necessary.
But I found in the HeaderClientChannel class, in the function
void HeaderClientChannel::messageChannelEOF(),
after called closeCallback_->channelClosed(), then, the class assigns nullptr to the pointer:
closeCallback_ = nullptr;

In this case, memory leaking is occurred.
But I think in the asynchronous case, developer haven't the responsibility to holder a callback and free them.
And no any note to say, need to delete this in the function channelClosed().

problem installing related to folly

Some background I'm installing everything via

https://github.com/facebook/fblualib/blob/master/install_all.sh

I'm on ubuntu 14.04

Relevant part of configure

checking folly/String.h usability... yes
checking folly/String.h presence... no
configure: WARNING: folly/String.h: accepted by the compiler, rejected by the preprocessor!
configure: WARNING: folly/String.h: proceeding with the compiler's result
checking for folly/String.h... yes

After configuring for fbthrift I run

$ make

The output I get is

make all-recursive
make[1]: Entering directory /tmp/fblualib-build.uzwQS9/fbthrift/thrift' Making all in compiler make[2]: Entering directory/tmp/fblualib-build.uzwQS9/fbthrift/thrift/compiler'
make all-recursive
make[3]: Entering directory /tmp/fblualib-build.uzwQS9/fbthrift/thrift/compiler' Making all in . make[4]: Entering directory/tmp/fblualib-build.uzwQS9/fbthrift/thrift/compiler'
make[4]: Nothing to be done for all-am'. make[4]: Leaving directory/tmp/fblualib-build.uzwQS9/fbthrift/thrift/compiler'
Making all in py
make[4]: Entering directory /tmp/fblualib-build.uzwQS9/fbthrift/thrift/compiler/py' /usr/bin/python setup.py build running build running build_py copying ./frontend.so -> build/lib.linux-x86_64-2.7/thrift_compiler mkdir -p ../../.python-local/lib/python PYTHONPATH=../../.python-local/lib/python /usr/bin/python setup.py install --home=../../.python-local running install running build running build_py running install_lib copying build/lib.linux-x86_64-2.7/thrift_compiler/frontend.so -> ../../.python-local/lib/python/thrift_compiler running install_egg_info Removing ../../.python-local/lib/python/thrift_py-0.9.0.egg-info Writing ../../.python-local/lib/python/thrift_py-0.9.0.egg-info make[4]: Leaving directory/tmp/fblualib-build.uzwQS9/fbthrift/thrift/compiler/py'
make[3]: Leaving directory /tmp/fblualib-build.uzwQS9/fbthrift/thrift/compiler' make[2]: Leaving directory/tmp/fblualib-build.uzwQS9/fbthrift/thrift/compiler'
Making all in lib
make[2]: Entering directory /tmp/fblualib-build.uzwQS9/fbthrift/thrift/lib' Making all in thrift make[3]: Entering directory/tmp/fblualib-build.uzwQS9/fbthrift/thrift/lib/thrift'
../../compiler/thrift1 --gen cpp:templates,cob_style -r reflection.thrift
../../compiler/thrift1: error while loading shared libraries: libfolly.so.3: cannot open shared object file: No such file or directory
make[3]: *** [gen-cpp/reflection_constants.cpp] Error 127
make[3]: Leaving directory /tmp/fblualib-build.uzwQS9/fbthrift/thrift/lib/thrift' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory/tmp/fblualib-build.uzwQS9/fbthrift/thrift/lib'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/fblualib-build.uzwQS9/fbthrift/thrift'
make: *** [all] Error 2

I have libfolly.so.3 in /usr/local/lib

After digging through previous issues to try to find something and I think it might be related to CPPFLAGS or something like that in the configuration.

$ cat config.log | grep CPPFLAGS

outputs

ac_cv_env_CPPFLAGS_set=set
ac_cv_env_CPPFLAGS_value=
AM_CPPFLAGS='-I$(top_srcdir)/.. -pthread -I/usr/include'
BOOST_CPPFLAGS='-pthread -I/usr/include'
CPPFLAGS=''
LIBEVENT_CPPFLAGS=''
PYTHON_CPPFLAGS='-I/usr/include/python2.7'
ZLIB_CPPFLAGS=''

I'm not familiar with C++ build tools so I'm not sure how to go about configuring all these things.

I also tried using deps.sh that run into the same issue, although I think it's for ubuntu 12.10 anyway.

Thanks

Configuring Idle connection time CPP2 ThriftServer

We are running into the following issue. We have a proxy (CPP2 server + client) which manages connections to a bunch of backend servers - the backend servers are CPP2 ThriftServer. We see that if the connection remains idle for a while (no requests) - the connect is closed and we suspect this is because the CPP2 ThriftServer closes connections idle for a certain period of time. We start seeing a large number of "Channel is !good inside our proxy at this point". We have two options:

  1. Increasing this time to infinity - this would make our proxy control connections completely and since the stack is all CPP2, we can get away with very few connections either ways

  2. Doing more connection management in the proxy which would be painful. Is it possible to perform a "reconnect" on a TAsyncSocket which is no longer "good()" ?

Bad symbolic link?

thrift/compiler/thrifty.yy.h seems to be a bad symbolic link?

$ ls -la thrift/compiler/thrifty.yy.h
lrwxr-xr-x 1 vagrant vagrant 9 Jun 26 01:09 thrift/compiler/thrifty.yy.h -> thrifty.h

EventHandler not work after use eb->runInEventBaseThread

In Duplex Server. I use server->setServerEventHandler function to add a EventHandler. I want to do some work after a connection destroyed. But if I use eb->runInEventBaseThread to push a msg to the client, the EventHandler will not work after that(maybe after the HeaderClientChannel::sendRequest is called). How can I make it work?

thrift1 to thrift2 chaining doesn't work on OSS build

Hi

I was able to build fbthrift on centos. It added "thrift1" binary. Now when I try to generate cpp code for a simple service it does not generate async_ interface that I want. Is there any option that I need to give it?

HandlerCallback eventbase thread in CPP2 ThriftServer

When using the CPP2 ThriftServer, does the HandlerCallback run the exception() and result() calls in the correct eventbase thread (corresponding to socket) or does that need to be taken care of as well, in case we have a context switch.

Thanks !

cpp2 can't communicate w/ python CppServer

I have a simple python server

class TestHandler:
  def test():
    print("hello world")

handler   = TestHandler()
processor = TestService.Processor(handler)
server = TCppServer.TCppServer(processor)
server.setPort(11216)
print('Started the server...')
server.serve()
print('done.')

Before I run this server I do a

  export GLOG_v=10
  export GLOG_minloglevel=0 
 export GLOG_stderrthreshold=0

My cpp2 client looks like this

  template<typename T>
  inline std::shared_ptr<T> tclient(apache::thrift::async::TEventBase &eventLoop
                                    , const std::string &host
                                    , const uint16_t port) {
    using namespace apache::thrift::async; // TAsyncSocket
    using namespace apache::thrift;
    std::shared_ptr<TAsyncSocket> socket =
      TAsyncSocket::newSocket(&eventLoop, host, port);
    return std::make_shared<T>(HeaderClientChannel::newChannel(socket));
  }

The little python server starts and runs but I see this in the logs after exposing the glog to verbose=6

I1207 21:06:01.315920 25985 Cpp2Connection.cpp:378] Channel 127.0.0.1:58106 closed: N6apache6thrift9transport19TTransportExceptionE: Channel Closed
I1207 21:06:01.315945 25985 TAsyncSocket.cpp:505] TAsyncSocket::setReadCallback() this=0x7f4820000a70, fd=30, callback=0, state=2
I1207 21:06:01.315961 25985 TAsyncSocket.cpp:505] TAsyncSocket::setReadCallback() this=0x7f4820000a70, fd=30, callback=0, state=2
I1207 21:06:01.315978 25985 TAsyncSocket.cpp:789] TAsyncSocket::closeNow(): this=0x7f4820000a70, fd_=30, state=2, shutdownFlags=4
I1207 21:06:01.316046 25985 TAsyncSocket.cpp:505] TAsyncSocket::setReadCallback() this=0x7f4820000a70, fd=-1, callback=0, state=3
I1207 21:06:01.316064 25985 Cpp2Channel.cpp:228] Got an EOF on channel

The rpc call looks like this

  client->test(
  [](apache::thrift::ClientReceiveState && state) {
    if(state.isException()) {

      LOG(INFO) << "Exception test. \n"
                << "proto id" << state.protocolId() << "\n"
                << "Exception: "
                << state.exceptionWrapper().what() << " \nClass Name "
                << state.exceptionWrapper().class_name();
    }else {
      LOG(INFO) << "finished";
    }
  });

The issue

the python server doesn't actually call the handler

Things that i've tried to get a cpp2 client talking to a python server

1st Note the _cpp_server_wrapper.so is not built with the regular makefile.

I built a little Sconstruct file to generate it and it loads fine.

import os


libs = [
    "thriftcpp2"
    ,"thriftz"
    ,"thrift"
    ,"krb5"
    ,"gssapi_krb5"
    ,"boost_thread"
    ,"ssl"
    ,"crypto"
    ,"rt"
    ,"pthread"
    ,"folly"
    ,"snappy"
    ,"gflags"
    ,"glog"
    ,"boost_system"
    ,"event"
    ,"z"
    ,"bz2"
    ,"lz4"
    ,"lzma"
    ,"snappy"
    ,"double-conversion"
    ,"krb5"
    ,"gssapi_krb5"
    ,"sasl2"
    ,"numa"
    ,"ssl"
    ,"gflags"
    ,"crypto"
    ,"rt"
    ,"pthread"
    ,"python2.7"
    ,"boost_python"
]

path = ["$TLD/include", "$TLD/lib"]
cxxflags = [
    "-isystem /usr/include/python2.7"
    ,"-std=c++11"
]
env = Environment(ENV = os.environ
                  , LD = "ld.gold"
                  , NUM_CPU = 4
                  , JOBS = 8
                  , CC = "ccache gcc-4.9"
                  , CXX = "ccache g++-4.9"
                  , CCFLAGS = " ".join(cxxflags)
                  , LDFLAGS = " -v")


env.SharedLibrary(target="_cpp_server_wrapper", source = Glob("*.cpp"), LIBS=libs)

I've also tried a plain TNonBlockingServer with both binary and theader protocols

class TestHandler:
  def test():
    print("hello world")

handler   = TestHandler()
processor = TestService.Processor(handler)
pfactory = TBinaryProtocol.TBinaryProtocolFactory()
# pfactory = THeaderProtocol.THeaderProtocolFactory(strictRead=False,
#                                                   client_types=
#                 [THeaderTransport.HEADERS_CLIENT_TYPE,
#                  THeaderTransport.FRAMED_DEPRECATED,
#                  THeaderTransport.UNFRAMED_DEPRECATED])
transport = TSocket.TServerSocket(11216)
server = TNonblockingServer.TNonblockingServer(
  processor, transport, pfactory,readTimeout=2000)

print('Started the server...')
server.serve()
print('done.')

Which starts up as well (same issue).

My reasoning is that instead of a HeaderClientChannel you'll need a TBinaryAsyncClientChannel but this file is not installed in /usr/local/inbluce/thrift/lib/cpp/async/* which left me wondering what to do next.

Thanks you for any help / pointers.

PS: I would have posted to a google groups of something for this library, but I didn't see anything, maybe it would be worth starting one.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.