Resolving service invocation timeout errors with Dapr and mDNS on OSX

Catalin Tomescu
3 min readDec 30, 2022

--

Dapr is short for “Distributed Application Runtime” developed by Microsoft, but open-source, that makes microservices development easy.

Problem

The runtime is portable and cross platform meaning you can develop on any operating system where your language of choice has an ADK and run-time. For me the language is .NET 6 and it happens that my personal computer is a MBP M1.

After setting up Dapr I was ready to start learning and play with some code. The Dapr documentation is very good and a convenient list of Quickstarts can get you up and running in no time. One of the building blocks of Dapr is service invocation. The quickstart doc for this block is here.

If you are on OSX like me you may have seen issues with Dapr trying to discover other services while running locally. The issue I’m describing here is related to using mDNS location service.

Troubleshooting

To determine if your issue is related to mDNS add following flags to the dapr command: --log-level debug and --enable-api-logging. First flag is self explanatory. Second one shows the traffic between Dapr sidecar and your application. After I enabled these flags I was able to see error messages like this:

DEBU[0001] mDNS response for app id order-processor received. app_id=checkout instance=… scope=dapr.contrib type=log ver=1.9.5
DEBU[0001] Adding IPv4 address 10.x.x.x:59550 for app id order-processor cache entry. app_id=checkout instance=… scope=dapr.contrib type=log ver=1.9.5

The important part here is 10.x.x.x which is the IP address that Dapr picked up from your OS network configuration. This is where things can go wrong especially if you are running a VPN or other security software. If this IP address is “exotic” mDNS will not be able to resolve a service (app-id).

One more check you can do is by running this command ifconfig | grep inet and see what IPs show up there. Anything other then 192.x.x.x or 127.0.0.1 may be picked up by Dapr and used as your local IP.

This article in the Dapr docs describes this common issues “I’m getting timeout/connection errors when running Actors locally”.

Solution

The fix on OSX is to create a separate profile in the Network configuration and leave only the Wi-Fi or Ethernet service that you are using while doing development.

Here is a screen shot of a simple configuration with Wi-Fi and nothing else.

  1. Create a new Location (name it anything you’d like)
  2. Select Wi-Fi or Ethernet
  3. Select your Wi-Fi network
  4. After you connect you’ll get an IP address in the range 191.168.1.x

After making this configuration change re-open your IDE and run the dapr commands for your application.

As described in the Dapr article that I linked above you could useexport DAPR_HOST_IP=yourIP but this means that you have to run this every time your IP is renewed by your Wi-Fi router DNS server.

I hope this helps some of you that are developing with .NET on OSX and use Dapr runtime.

--

--

Catalin Tomescu

Passionate about designing, building and testing software. Opinions are my own.