Search code examples
timeoutreverse-proxyazure-service-fabricgateway

Service Fabric Reverse Proxy


I am facing issues getting Reverse Proxy right. I keep getting "504 Getaway Timeout" when I am using the Reverse Proxy.

I have followed the Microsoft's example to set up the cluster.

IMHO, I think cluster set-up is correct, the only difference is that I've specified port 80 for the proxy and I did not use SSL for test env.

I am trying it out on test environment at the moment, but the production environment is running the same services, just w/o reverse proxy and it is just fine. Also, I have exposed an endpoint for one of the services on test env, tried calling it w/o reverse proxy and it worked.

I've read that it could be caused by the containers, but I am using Windows 2012 RC2 DataCenter. As far as I am aware, it does not utilize windows nat containers. Also, I've read that it could be caused by the 404 error (#case 2 in the example doc) where it tries to reload it and simply times out trying.

These are some of the summed up details that might be important to know

  • Service Fabric version: 5.5.219.0
  • OS: Windows
  • SKU: 2012-R2-Datacenter
  • Services are using WebListener
  • All ports are allowed
  • 1 NodeType (stateless)
  • Services created with ASP.NET Core Web API template
  • VS 2015 Enterprise

Service endpoints are configured like follows: Endpoint Protocol="http" Name="ServiceEndpoint" Type="Input"

All services and cluster are healthy.


Solution

  • I have found a cause for this timeout. It was just me not getting the required change in the request url right.

    All of my services are holding MVC controllers that are named after service name. So whenever I was calling them without reverse proxy my request url would be something like http://mycluster.westeurope.cloudapp.azure.com:8280/Notifications/TestMethod

    and this would be enough as it could find Controller by unique port. The way I've been trying to call it with reverse proxy was http://mycluster.westeurope.cloudapp.azure.com/SomeName.API.Services/Notifications/TestMethod

    That is not enough as 'Notifications' is parsed as a name of the service and not the controller. So I was calling the service and an action without specifying a controller.

    The correct way to call it is to include service name twice, since I've called my controllers the same as service (I might change that). Here is a correct url I have to use http://mycluster.westeurope.cloudapp.azure.com/SomeName.API.Services/Notifications/Notifications/TestMethod

    I have figured it out by looking up the reverse proxy code sample.