While working from home I was trying to use MSDeploy (aka Web Deploy, or the Publish Web command in Visual Studio 2010) to update an internal site. Whilst this would work perfectly when I was physically in the office, when working from home via the VPN it would fail with the following error:
Remote agent (URL http://myserver.example.com/MSDEPLOYAGENTSERVICE) could not be contacted. Make sure the remote agent service is installed and started on the target computer. An unsupported response was received. The response header 'MSDeploy.Response' was '' but 'v1' was expected. The remote server returned an error: (400) Bad Request.
To see what was going on I started Fiddler and tried the publish again. (One crucial thing I had to do for Fiddler to capture traffic when connected via the VPN was to fully qualify the machine name, so instead of http://myserver, use http://myserver.your-corp.net as the service URL, otherwise it didn’t capture the traffic.)
This is what the exchange looked like:
POST http://myserver.example.com/MSDEPLOYAGENTSERVICE HTTP/1.1 MSDeploy.VersionMin: 7.1.600.0 MSDeploy.VersionMax: 7.1.1042.1 MSDeploy.RequestUICulture: en-US MSDeploy.RequestCulture: en-GB Version: 220.127.116.11 MSDeploy.Method: Sync MSDeploy.RequestId: fde03509-b23e-4759-9353-e8dbf19a2293 Content-Type: application/msdeploy MSDeploy.ProviderOptions: H4sIAAAAAAAEAO29B2AcSZYlJi9tynt... MSDeploy.BaseOptions: H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvV... MSDeploy.SyncOptions: H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvV... Host: myserver.example.com Transfer-Encoding: chunked Expect: 100-continue ...
And in response:
HTTP/1.1 400 Bad Request (The HTTP request includes a non-supported header. Contact your ISA Server administrator.) Via: 1.1 IBISA2 Connection: Keep-Alive Proxy-Connection: Keep-Alive Pragma: no-cache Cache-Control: no-cache Content-Type: text/html ...
There in the clear was the crucial error information that MSDeploy was failing to relay: those whacky MSDeploy HTTP Headers were being blocked by our ISA Server. (Note to the developers of MSDeploy: showing this information in debug or verbose modes would be very useful!)
After specifying an access rule on the ISA server to not filter proxied requests to the server in question based on HTTP headers, it all started working again.