thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gianni Ambrosio <gianni.ambro...@vi-grade.com>
Subject Unable to stop socket server while there are connected clients
Date Tue, 27 Feb 2018 13:09:19 GMT
Hi All,
I was experiencing exacly the same problem reported here with Thrift 0.9.1:
https://issues.apache.org/jira/browse/THRIFT-2696

  So I moved to the latest thrift version (i.e. 0.11.0) but the problem 
is still there!

I implemented a thrift server with TSimpleServer in C#:

public class ThriftServer
{
    public void start(){
       Service.Processor processor = new Service.Processor(serviceHandler);
       TServerSocket serverTransport = new 
TServerSocket(ServiceConstants.ServicePort);
       server = new TSimpleServer(processor, serverTransport);
       workerThread = new Thread(new ThreadStart(run));
       workerThread.Start();
    }
    private void run(){
       server.Serve();
    }
    public void stop(){
       server.Stop();
    }
}

And here is the C++ client implementation:

void ThriftClient::connect(const std::string& serverIp) {
boost::shared_ptr<apache::thrift::transport::TTransport> socket(new 
apache::thrift::transport::TSocket(serverIp.c_str(), 
g_Service_constants.ServicePort));
    transport = 
boost::make_shared<apache::thrift::transport::TBufferedTransport>(socket);
    transport->open();
    client = 
boost::make_shared<ServiceClient>(boost::make_shared<apache::thrift::protocol::TBinaryProtocol>(transport));
}

The problem is that when I close the C# application the application does 
not close. But in that state it closes as soon as I close the C++ client 
application.
Debugging the C# application, server.Stop() is called but server.Serve() 
call does not exit unless the client has been disconnected.
Since the above thrift ticket seems reporting exactly the same issue and 
it should be fixed in thrift 0.9.2, what's wrong in my code?

Best regards,
Gianni


Mime
View raw message