Search code examples
c#azurethriftwindows-server-2012

Apache Thrift remote service timeout


I set up Thrift to build two entities and a corresponding service. I genereated the code for C#, created a small console application for the server and another one for a test client. I ran both on my local machine and it worked like a charm. But when deploying the server on my Azure VM running Windows Server 2012, with an endpoint created on port 9090 for TCP, my client can't connect. There's a timeout.

Similar questions on SO: This one is about a php library specific problem and this one is about two linux machines. The latter one is close to my question, but I can imagine my problem is Windows or Azure VM specific.

I'm using Thrift 0.9.0.0 from NuGet. I tried SimpleServer and ThreadPoolServer. This is what I'm doing on the server:

Thrift.Server.TServer server = new Thrift.Server.TThreadPoolServer(new TodoThriftService.Processor(new TodoThriftServiceHandler()), new TServerSocket(9090));

This is what I'm doing on the client:

TodoThriftService.Client client = new TodoThriftService.Client(new TBinaryProtocol(new TSocket("my.host.com", 9090)));

I also tried the server IP address instead of its host name, but it didn't work either.

netstat -an output is:

TCP    0.0.0.0:9090           0.0.0.0:0              LISTENING

Output from telnet from client (telnet my.host.com 9090):

Verbindungsaufbau zu my.host.com...Es konnte keine Verbindung mit dem Host hergestellt werden, auf Port 9090: Verbindungsfehler

Which is German for "connection error".

When I visit http://canyouseeme.org/ on the server and check port 9090 the output is:

Error: I could not see your service on 123.34.567.890 on port (9090). Reason: Connection timed out

When I sniff packets with Wireshark on the server the output is:

1   0.000000000 12.3.456.78 12.34.567.89    TCP 66  53566 > websm [SYN] Seq=0 Win=8192 Len=0 MSS=1452 WS=256 SACK_PERM=1

And two retransmissions.

Note: The destination IP shown in Wireshark differs from the IP that canyouseeme.org determined.

Also note: Both connection attempts from my test client as well as from canyouseeme.org are shown in Wireshark.

Is my server console application doing anything wrong? It works fine on my local machine.


Solution

  • Because netstat reports that your server is listening on 9090, and because tcpdump reports that SYN packets are arriving to 9090, something else must be blocking the client.

    My suspicion in this case would be some sort of local firewall (because the packets did arrive, but the OS should have answered with a SYN packet and you didn't see that). Check Windows Firewall to make sure port 9090 is open.