title: Web deployment task failed. Could not connect...server did not respond
body: <p>I've been publishing my Lightswitch app using Visual Studio 2012 RC to my localhost (Win 7, SQL 2008 R2, IIS 7.5) just fine. Now I'm trying to publish to a remote server (Win 2008 R2, SQL 2008 R2, IIS 7.5) and I'm having trouble.</p>
  
  <p>When I try to Publish, I receive the following error:</p>
  
  <blockquote>
    <p>Web deployment task failed. (Could not connect to the remote computer
    ("###.###.###.###") using the specified process ("Web Deployment Agent
    Service") because the server did not respond. Make sure that the
    process ("Web Deployment Agent Service") is started on the remote
    computer.  Learn more at:
    <a href="http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_COULD_NOT_CONNECT_TO_REMOTESVC" rel="noreferrer">http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_COULD_NOT_CONNECT_TO_REMOTESVC</a>.)</p>
  </blockquote>
  
  <p>I've checked each of the things the "learn more" link suggests to check. I have verified that MsDepSvc and WMSVC are both running and Ports 80 and 8172 are both responding to port scans. In the Publish settings, for the Service URL, I'm using the IP address (<a href="http://###.###.###.###" rel="noreferrer">http://###.###.###.###</a>) of the remote machine. For the User Name, I'm using DomainName\Administrator which is what I use to log on using RDP.</p>
  
  <p>I've posted on the <a href="http://social.msdn.microsoft.com/Forums/en-US/lightswitch/thread/19197323-6d97-4252-a2c3-c34ebdaf0f46/" rel="noreferrer">MSDN Forums</a> where a member suggested I roll back the Web Deployment Tool from V2.0 to V1.1. Which I've done, but it did not change anything.</p>
  
  <p>Following the advice in an answer to this <a href="https://stackoverflow.com/questions/6188418/problem-using-web-deploy-with-iis-6">SO Question</a> I've tried running <code>msdeploy</code> from the command line.</p>
  
  <p>From the command line on the <strong><em>server</em></strong> I get:</p>
  
  <blockquote>
    <p>C:\Program Files\IIS\Microsoft Web Deploy>msdeploy -verb:dump
    -source:dirpath=c:\temp,computername=<a href="http://SeverName:80/msdeployagentservice,username=Administrator,password=XXXX" rel="noreferrer">http://SeverName:80/msdeployagentservice,username=Administrator,password=XXXX</a>
    -verbose -debug Verbose: Using ID 'c12c3392-2290-44b7-9434-dbd0ff5f9385' for connections to the remote
    server. Verbose: Pre-authenticating to remote agent URL
    '<a href="http://ServerName:80/msdeployagentservice" rel="noreferrer">http://ServerName:80/msdeployagentservice</a>' as 'Administrator'.
    MSDeploy.dirPath (name=MSDeploy.dirPath) c:\temp (name=dirPath)
    (keyAttribute=c:\temp) (linkName=Child1)</p>
  </blockquote>
  
  <p>From the command line on the <strong><em>dev machine</em></strong> I get:</p>
  
  <blockquote>
    <p>C:\Program Files\IIS\Microsoft Web Deploy V3>msdeploy -verb:dump
    -source:dirpath
    =c:\temp,computername=<a href="http://###.###.###.###:80/msdeployagentservice,username=Administrator,password=XXXX" rel="noreferrer">http://###.###.###.###:80/msdeployagentservice,username=Administrator,password=XXXX</a> -verbose -debug Info: Using ID '7f0b7d5b-e202-424c-a7dd-246920253081' for connections to the remote server. Verbose: Pre-authenticating to
    remote agent URL '<a href="http://###.###.###.###:80/msdeployagentservice" rel="noreferrer">http://###.###.###.###:80/msdeployagentservice</a>' as
    'Administrator'. Verbose: Pre-authenticating to remote agent URL
    '<a href="http://###.###.###.###:80/msdeployagentservice" rel="noreferrer">http://###.###.###.###:80/msdeployagentservice</a>' as 'Administrator'.
    Error Code: ERROR_COULD_NOT_CONNECT_TO_REMOTESVC More Information:
    Could not connect to the remote computer ("###.###.###.###") using the
    specified process ("Web Deployment Agent Service") because the server
    did not respond. Make sure that the process ("Web Deployment Agent
    Service") is started on the remote computer.  Learn more at:
    <a href="http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_COULD_NOT_CONNECT_TO_REMOTESVC" rel="noreferrer">http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_COULD_NOT_CONNECT_TO_REMOTESVC</a>.
    Learn more at:
    <a href="http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_COULD_NOT_CONNECT_TO_REMOTESVC" rel="noreferrer">http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_COULD_NOT_CONNECT_TO_REMOTESVC</a>.
    ---> Microsoft.Web.Deployment.DeploymentException: Object of type 'dirPath' and path 'c:\temp' cannot be created. --->
    System.Net.WebException: The remote server returned an error: (400)
    Bad Request.    at System.Net.HttpWebRequest.GetResponse()    at
    Microsoft.Web.Deployment.AgentClientProvider.GetHttpResponse(HttpWebRequest
    request)    --- End of inner exception stack trace ---    --- End of
    Inner Exception Stack Trace ---    at
    Microsoft.Web.Deployment.DeploymentManager.CreateObjectPrivate(DeploymentProviderContext
    providerContext, DeploymentBaseOptions baseOptions, DeploymentObject
    sourceObject, String serverVersion)    at
    Microsoft.Web.Deployment.DeploymentManager.CreateObject(DeploymentProviderOptions
    providerOptions, DeploymentBaseOptions baseOptions)    at
    MSDeploy.MSDeploy.CreateObject(DeploymentProviderOptions
    providerOptions, DeploymentBaseOptions baseOptions)    at
    MSDeploy.MSDeploy.ExecuteWorker()    at MSDeploy.MSDeploy.Execute()<br>
    at MSDeploy.MSDeploy.Main(String[] unusedArgs) Error count: 1.</p>
  </blockquote>
  
  <p>Using Wireshark, I find that I am logging in okay but after a <code>POST /MSDEPLOYAGENTSERVICE</code> I'm getting an Error 400: Bad request that looks like this:</p>
  
  <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"&gt;\r\n
  &lt;HTML&gt;&lt;HEAD&gt;&lt;TITLE&gt;Bad Request&lt;/TITLE&gt;\r\n
  &lt;META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"&gt;&lt;/HEAD&gt;\r\n
  &lt;BODY&gt;&lt;h2&gt;Bad Request - Invalid Content Length&lt;/h2&gt;\r\n
  &lt;hr&gt;&lt;p&gt;HTTP Error 400. There is an invalid content length or chunk length in the request.&lt;/p&gt;\r\n
  &lt;/BODY&gt;&lt;/HTML&gt;\r\n
  </code></pre>
  
  <p>The only thing I could find that mentioned this specific behavior was a <a href="http://support.microsoft.com/kb/300707" rel="noreferrer">Microsoft Support Article</a> for ISA Server 2000.</p>
  
  <p>What else should I be looking at?</p>