You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Robert Kalem <ro...@isystem.si> on 2022/09/30 08:21:18 UTC

Can't connect to async C# server with C++ client

Hi,

I've got a task of evaluating Thrift so I wanted to make some simple tests
but got stuck on the issue described here.
I've successfully generated C# (netstd) files and created an async server
and matching client that seem to be working fine. Then I created a Python
client which also works fine with the async C# server.
I wanted to do the same with C++ client, but the client cannot talk to the
C# server.
The message I get:

> Thrift: Thu Sep 29 13:25:07 2022 TSocket::open() connect() <Host:
> localhost Port: 9090>: No connection could be made because the target
> machine actively refused it.


I also tried generated C++ sync client and server which work fine. I also
tried manually changing the code and creating an async server which also
worked fine.



So I would need a C++ client that would talk to the C# server (generated
async by default)
Are there any restrictions/known issues for this type of communication?
Thank you for your help.


Robert



I attached the C# server and C++ client code:

*C# server*

static async Task Main(string[] args)
        {
            TConfiguration Configuration = null;

            var protoFactory = new TBinaryProtocol.Factory();  //
binary/compact/JSON
            var transFactory = new TFramedTransport.Factory(); // another
option is buffered transport (TBufferedTransport)
            var handler = new HelloWorldServiceHandler();
            Thrift.Processor.ITAsyncProcessor processor = new
HelloWorldService.AsyncProcessor(handler);
            ILogger logger = null;

            var servertrans = new TServerSocketTransport(9090,
Configuration);

            var server = new TSimpleAsyncServer(new
Thrift.Processor.TSingletonProcessorFactory(processor), servertrans,
                transFactory, transFactory, protoFactory, protoFactory,
logger);

            await server.ServeAsync(CancellationToken.None);
        }


*C++ client*

int main() {
    int64_t x, y;
    x = 4; y = 5;
    shared_ptr<TTransport> trans;
    trans = make_shared<TSocket>("localhost", 9090);
    trans = make_shared<TFramedTransport>(trans);
    auto proto = make_shared<TBinaryProtocol>(trans);
    serverTest::HelloWorldServiceClient client(proto);
    try {
        trans->open();
        int64_t productOfMultiply;
        std::cin >> x >> y;
        productOfMultiply = client.Multiplication(x, y);
        printf("The result is : %lld ", productOfMultiply);
    }
    catch (...) {
        printf("Client caught an exception");
    }
    trans->close();
}


Best Regards,

*Robert Kalem *
Software Engineer
iSYSTEM Labs d.o.o.
Brodišče 18, 1236 Trzin, Slovenia
robert.kalem@isystem.si
www.isystem.com