title: Non-Blocking Thrift Server in C++ and Thrift Client in Python
body: <p>I have a non-blocking multi-threaded thrift server written in C++ and a thrift client written in python. Below code snippets briefly shows how the thrift protocol and binding configurations are done in both C++ server and python client.</p>
  
  <p>My problem is that when the python client makes a call to the C++ server via thrift I get an error saying "<strong>thrift non-blocking server overload condition</strong>" in the C++ server output (i.e. terminal), which have been indicated in the 3rd and 4th snippets below. I am enclosing the stack that is retrieved via GDB backtrace command as well for your information. Can anyone tell me what I am missing here? What do you think could be the possible cause of this error. Is there st wrong in the thrift configuration in python side or C++ side. Please refer to the below snippets. I made a lot of googling but could not find a clue so far. Thanks.</p>
  
  <p><strong>1) Python Client - Thrift Configuration</strong></p>
  
  <pre><code>     try:
          self.transport = TSocket.TSocket( host , port)
          &lt;----- NONBLOCKING ---------&gt;
          self.transport = TTransport.TFramedTransport(self.transport)    
          &lt;----- NONBLOCKING ---------&gt;
          protocol = TBinaryProtocol.TBinaryProtocol(self.transport)
  
  
          # Instantiate the thrift client
          self.client = MyService.Client(protocol)
          # Connect to the thrift server
          self.transport.open()
          print 'Connection established via thrift...\n'   
  </code></pre>
  
  <p><strong>2) C++ server - Thrift configuration</strong></p>
  
  <pre><code>    using boost::shared_ptr;
      printf("          *** Starting non-block THRIFT! ***\n");
      shared_ptr&lt;MyServiceHandler&gt; handler(new MyServiceHandler(this));
      shared_ptr&lt;TProcessor&gt; processor(new MyServiceProcessor(handler));
      shared_ptr&lt;TProtocolFactory&gt; protocolFactory(new TBinaryProtocolFactory());
  
      shared_ptr&lt;ThreadManager&gt;  threadManager=ThreadManager::newSimpleThreadManager(15);
      shared_ptr&lt;PosixThreadFactory&gt; threadFactory =
      shared_ptr&lt;PosixThreadFactory&gt;(new PosixThreadFactory());
      threadManager-&gt;threadFactory(threadFactory);
      threadManager-&gt;start();
      ats::TNonblockingServer server(processor,protocolFactory, port, threadManager);
      server.serve();
  </code></pre>
  
  <p><strong>3) Error Output in C++ server</strong></p>
  
  <pre><code>   !!!! ERROR BEGIN !!!! 
     Thrift: Tue Nov 15 17:59:49 2011 **thrift non-blocking server overload condition**
     !!!! ERROR IS END !!!!
  </code></pre>
  
  <p><strong>4) GDB Backtrace Stack</strong></p>
  
  <pre><code>   thrift non-blocking server overload condition
  
     Program received signal SIGSEGV, Segmentation fault.
     [Switching to Thread 0xb7ad7b70 (LWP 17961)]
     0x080bb3a8 in vtable for __cxxabiv1::__si_class_type_info ()
    (gdb) bt
    #0 0x080bb3a8 in vtable for __cxxabiv1::__si_class_type_info ()
    #1 0xb7ec8195 in apache::thrift::server::TConnection::workSocket (this=0x80be4f0)
    at src/server/TNonblockingServer.cpp:168
    #2 0xb7ecc88d in apache::thrift::server::TConnection::eventHandler (fd=13, v=0x80be4f0)
    at src/server/TNonblockingServer.h:915
    #3 0xb7ea8e90 in event_base_loop () from /usr/lib/libevent-1.4.so.2
    #4 0xb7ec782f in apache::thrift::server::TNonblockingServer::serve (this=0xb7ad7194)
    at src/server/TNonblockingServer.cpp:923
    #5 0x0807bef5 in MyConfiguration::runNonBlockingServer (this=0xbffff2ec, port=9090)
    at /home/configuration/my_configuration.cpp:485
    #6 0x0807de19 in MyConfiguration::run (this=0xbffff2ec)
    at /home/configuration/my_configuration.cpp:54
    #7 0x08078a2a in redirectPthreadRun (m=0xbffff2ec)
    at /home/src/common/p_thread_run.cpp:107
    #8 0xb7fa0725 in start_thread () from /lib/libpthread.so.0
    #9 0xb7ceb1ce in clone () from /lib/libc.so.6
  </code></pre>