Is it one of those rainy days where you sit in front of your Mac and would like to try out the latest and greatest Xamarin features like Xamarin.Forms and then Visual Studio refuses to connect to the Xamarin Build Host?
You did not change anything of course. It just stopped working over night. That’s what computers do to keep us busy. Your options: Xamarin support? Takes to long, so let’s resolve this all by ourselves.
The first stop is the diagnosis tool in Visual Studio under Tools -> Xamarin -> iOS Settings
If everything works, you’ll get a lot of green Passed, like in the screenshot above.
In my case however the tool was stuck at Connection to Mac Server – and it it would never complete.
The first thing to check: is the Xamarin Build Host App running? Do I hear you say “d’oh!“? It happens to the best.
Next, see if you can connect to the build host from your Mac. Fire up Terminal and type:
iMacBuero:~ rene$ telnet localhost 5000
This tries to establish a Telnet connection to the build host app on port 5000 – the default port which can currently not be configured (you can change it in the /Library/LaunchAgents/com.xamarin.mtvs.buildserver.plist but Visual Studio will not pick that change up – for reference see this bug report)
If this works, you’ll get an output like:
Trying ::1... Connected to localhost. Escape character is '^]'.
Now say “hello” to your build host:
Yep, it’s HELO with one L. If the handshake succeeds, the output will be:
If the handshake fails there will be an error or no output. In case there is no output, chances are that port 5000 is blocked by another application on the Mac. So let’s find out!
iMacBuero:~ rene$ lsof -i -P | grep 5000
This will give you a list of all processes using port 5000. In my case, AirServer is the culprit:
AirServer 505 rene 8u IPv4 0xb0ff6e06afaafe39 0t0 TCP *:5000 (LISTEN) AirServer 505 rene 9u IPv6 0xb0ff6e06a7b7cf71 0t0 TCP *:5000 (LISTEN)
So let’s shut down AirServer and retry…and voila! Issue resolved.