The underlying connection was closed: An unexpected error occurred on a send.RSS

7 replies

Last post Jan 09, 2020 10:47 PM by bvj

  • The underlying connection was closed: An unexpected error occurred on a send.

    Jul 27, 2015 02:23 PM|klpatil|LINK

    When doing Publish from Build server to Target server. We are seeing following error:

    Web deployment task failed. (Could not complete the request to remote agent URL 'https://<HOSTNAME/IP>:8172/msdeploy.axd?site=<OURWEBSITE>'.)

    This error indicates that you cannot connect to the server. Make sure the service URL is correct, firewall and network settings on this computer and on the server computer are configured properly, and the appropriate services have been started on the server.

    Error details: Could not complete the request to remote agent URL 'https://<HOSTNAME/IP>:8172/msdeploy.axd?site=<OURWEBSITE>'.

    The underlying connection was closed: An unexpected error occurred on a send.Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

    An existing connection was forcibly closed by the remote host                   0              0              WEBSITENAME

    We've been troubleshooting these since DAYS [Not hours] - We've read all following blogs/articles. Tried all possible solution. Bu with no luck:

    We’ve tried few things like :

    1. Disable Firewall/Antivirus, Allow Port 8172
    2. Make sure Hostname/IP gets resolved
    3. Server’s IP and Port number is reachable : Yes – We verified it using Telnet and it can connect to Port 8172  and also verified Firewall rules as well – All good!
    4. Verified all Web deploy related services are fine or not – and they are fine – We tried to run Powershell script given by Microsoft in Reference Link #2 – But no luck
    5. Verified username and password are fine – They are fine – Verified it using remote desktop with those credentials
    6. Reinstalled MSDeploy on SBX – and It didn’t helped
    7. No any log entry in MS Deploy IIS Log [HEAD/POST]
    8. Tried with MSDeploy command : msdeploy.exe -verb:dump -source:iisapp="Default Web Site",computername=https://<HOSTNAME>:8172/msdeploy.axd?site=Default%20Web%20Site,username=<USERNAME>,password=<PASSWORD>,authType=basic  -verbose –whatif
    9. Fired MS deploy command from my local – as given in earlier email and monitored packets on SBX server using TCPView and netstat command

    10. Found that : TCP Packet gets sent on 8172 and status : SYNC_RCVD – and then it drops packet
    11. As I understand this is how flow works:
       - Web Management Service listens on 8172
       - If request received it calls MsDeploy.axd
        Somehow, packet gets reached to Machine – But after that it should forward it to IIS – And in turn IIS will send it to MsDeploy – And looking at log files – Packet is being dropped at machine level

    References:

    1. http://stackoverflow.com/questions/12959501/web-deployment-task-failed-when-using-webdeploy-in-vs2012
    2. http://stackoverflow.com/questions/12959501/web-deployment-task-failed-when-using-webdeploy-in-vs2012
    3. http://www.iis.net/learn/publish/troubleshooting-web-deploy/troubleshooting-web-deploy-problems-with-visual-studio
    4. http://stackoverflow.com/questions/5841370/cant-get-my-ec2-windows-server-2008-web-stack-instance-to-receive-publishings
    5. http://stackoverflow.com/questions/11479927/visual-studio-2012-web-deploy-to-windows-server-2008-r2-with-iis-7-and-msdeploy
    6. http://stackoverflow.com/questions/11479927/visual-studio-2012-web-deploy-to-windows-server-2008-r2-with-iis-7-and-msdeploy

    Anything obvious -- We are missing?

    MsDeployHandlerVS2013WebDeploy

    Let me know if you need further assistance. I will be happy to help you.

    HTH

    -Kiran
    For more solution like this my blog is here
  • Re: The underlying connection was closed: An unexpected error occurred on a send.

    Jul 28, 2015 03:36 AM|Pengzhen Song - MSFT|LINK

    Hi,

    I suggest that you can check if you are using the right msdeploy publish url when publishing (open IIS manager--> r-click [yoursite]-->click "deploy"-->configure web deploy publishing...). And please make sure that check "enabled remote connections" for Management service.

    For more information, please refer to the document:

    http://www.asp.net/web-forms/overview/deployment/configuring-server-environments-for-web-deployment/configuring-a-web-server-for-web-deploy-publishing-(web-deploy-handler)

    In addition, please refer to the certificate issue:

    http://stackoverflow.com/questions/10894671/msdeploy-fails-for-webdeploy

    http://blogs.msdn.com/b/amol/archive/2011/02/09/errors-seen-while-using-msbuild-to-deploy-on-a-remote-iis-server-and-their-solutions.aspx

    Hope it can help you.

    MsDeployHandlerVS2013WebDeploy

    We are trying to better understand customer views on social support experience. Click HERE to participate the survey.
    Thanks!
  • Re: The underlying connection was closed: An unexpected error occurred on a send.

    Jul 29, 2015 03:47 AM|klpatil|LINK

    Thank you so much for your reply. My findings:

    Pengzhen Song - MSFT

    I suggest that you can check if you are using the right msdeploy publish url when publishing (open IIS manager--> r-click [yoursite]-->click "deploy"-->configure web deploy publishing...). And please make sure that check "enabled remote connections" for Management service.

    Have verified it in past. And verified again -- And I am sure it is hitting correct server. Because when I hit that URL using Browser -- Which prompts me for credentials -- Upon entering it. It shows me blank page, as msdeploy.axd is not allowed for GET -- and I can map that request in Web Deploy IIS Logs -- Yes Enable Remote Connections is enabled. Also, When I keep netstat on or TCP View -- I can see request coming on Web server

    Pengzhen Song - MSFT

    http://www.asp.net/web-forms/overview/deployment/configuring-server-environments-for-web-deployment/configuring-a-web-server-for-web-deploy-publishing-(web-deploy-handler)

    Thanks -- Have been through it again!

    Pengzhen Song - MSFT

    http://stackoverflow.com/questions/10894671/msdeploy-fails-for-webdeploy

    Have tried "msdeploy.exe -verb:dump -source:iisapp="Default Web Site",computername=https://<SERVERNAME>:8172/MsDeploy.axd?site=Default%20Web%20Site,username=<SERVERNAME>\USERNAME,password=************,authType=basic -allowUntrusted -verbose -showSecure"

    Have enabled logging as well : https://technet.microsoft.com/en-us/library/ff729439%28WS.10%29.aspx

    But I don't see any error -- So, I believe, Client is getting connected to Server. And then server is dropping packet. Before it goes and talk to msdeploy

    MsDeployHandlerVS2013WebDeploy

    Let me know if you need further assistance. I will be happy to help you.

    HTH

    -Kiran
    For more solution like this my blog is here
  • Re: The underlying connection was closed: An unexpected error occurred on a send.

    Jul 31, 2015 05:34 AM|klpatil|LINK

    After enabling System.Net Tracing in my local and providing MSDeploy command have found this error:

    System.Net Information: 0 : [10288] Enumerating security packages:
    System.Net Information: 0 : [10288]     Negotiate
    System.Net Information: 0 : [10288]     NegoExtender
    System.Net Information: 0 : [10288]     Kerberos
    System.Net Information: 0 : [10288]     NTLM
    System.Net Information: 0 : [10288]     TSSSP
    System.Net Information: 0 : [10288]     pku2u
    System.Net Information: 0 : [10288]     LiveSSP
    System.Net Information: 0 : [10288]     WDigest
    System.Net Information: 0 : [10288]     Schannel
    System.Net Information: 0 : [10288]     Microsoft Unified Security Protocol Provider
    System.Net Information: 0 : [10288]     CREDSSP
    System.Net Information: 0 : [10288] SecureChannel#29135240 - Left with 0 client certificates to choose from.
    System.Net Information: 0 : [10288] AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent  = Outbound, scc     = System.Net.SecureCredential)
    System.Net Information: 0 : [10288] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = (null), targetName = hcisrvr26_sbx, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
    System.Net Information: 0 : [10288] InitializeSecurityContext(In-Buffer length=0, Out-Buffer length=121, returned code=ContinueNeeded).
    System.Net.Sockets Verbose: 0 : [10288] Socket#46964992::Send()
    System.Net.Sockets Verbose: 0 : [10288] Data from Socket#46964992::Send
    System.Net.Sockets Verbose: 0 : [10288] 00000000 : 16 03 01 00 74 01 00 00-70 03 01 55 BB 3B 1A E0 : ....t...p..U.;..
    System.Net.Sockets Verbose: 0 : [10288] 00000010 : 02 87 35 F2 1D D5 8E 7B-FE A5 07 4A 73 CF 48 9A : ..5....{...Js.H.
    System.Net.Sockets Verbose: 0 : [10288] 00000020 : B9 C0 23 6B 67 AF 3F 0B-C1 BD 88 00 00 18 C0 14 : ..#kg.?.........
    System.Net.Sockets Verbose: 0 : [10288] 00000030 : C0 13 00 35 00 2F C0 0A-C0 09 00 38 00 32 00 0A : ...5./.....8.2..
    System.Net.Sockets Verbose: 0 : [10288] 00000040 : 00 13 00 05 00 04 01 00-00 2F 00 00 00 12 00 10 : ........./......
    System.Net.Sockets Verbose: 0 : [10288] 00000050 : 00 00 0D 68 63 69 73 72-76 72 32 36 5F 73 62 78 : ...hcisrvr26_sbx
    System.Net.Sockets Verbose: 0 : [10288] 00000060 : 00 0A 00 06 00 04 00 17-00 18 00 0B 00 02 01 00 : ................
    System.Net.Sockets Verbose: 0 : [10288] 00000070 : 00 23 00 00 FF 01 00 01-00                      : .#.......
    System.Net.Sockets Verbose: 0 : [10288] Exiting Socket#46964992::Send()     -> Int32#121
    System.Net.Sockets Verbose: 0 : [10288] Socket#46964992::Receive()
    System.Net.Sockets Error: 0 : [10288] Socket#46964992::UpdateStatusAfterSocketError() - ConnectionReset
    System.Net.Sockets Error: 0 : [10288] Exception in Socket#46964992::Receive - An existing connection was forcibly closed by the remote host.
    System.Net.Sockets Verbose: 0 : [10288] Exiting Socket#46964992::Receive()     -> Int32#0
    System.Net.Sockets Verbose: 0 : [10288] Socket#46964992::Dispose()
    System.Net Error: 0 : [10288] Exception in HttpWebRequest#28278595:: - The underlying connection was closed: An unexpected error occurred on a send..
    System.Net Information: 0 : [10288] Associating HttpWebRequest#28278595 with ServicePoint#8864859
    System.Net Information: 0 : [10288] Associating Connection#35619075 with HttpWebRequest#28278595

    MsDeployHandlerVS2013WebDeploy

    Let me know if you need further assistance. I will be happy to help you.

    HTH

    -Kiran
    For more solution like this my blog is here
  • Re: The underlying connection was closed: An unexpected error occurred on a send.

    Aug 07, 2015 03:50 AM|klpatil|LINK

    Hello Folks,

    We raised ticket with Microsoft Support folks and this has been fixed by changing Server URL to : http://<HOSTNAME/IP>  from : https://<HOSTNAME/IP>:8172/msdeploy.axd

    Reference link : https://msdn.microsoft.com/en-us/library/dd465337%28v=vs.110%29.aspx

    To be honest -- We haven't been able to find out why earlier URL was working earlier and not working now.

    Thank you,

    Kiran

    MsDeployHandlerVS2013WebDeploy

    Let me know if you need further assistance. I will be happy to help you.

    HTH

    -Kiran
    For more solution like this my blog is here
  • Re: The underlying connection was closed: An unexpected error occurred on a send.

    Apr 18, 2018 08:10 PM|tamtranthien|LINK

    I have the same issue and my case because I cloned the target Virtual Machine which causes the SSL certificate on the Management Service not correct anymore. I tried to select the correct one and it worked.

    IIS Management Service

  • Re: The underlying connection was closed: An unexpected error occurred on a send.

    Apr 26, 2019 04:16 PM|david.ferretti.fig|LINK

    I had the same problem, and it looks like there are several ways HTTPS/SSL/TLS can cause this message to appear. If the certificate is wrong like above, you'll get this issue. And if your local machine is attempting to use a version of TLS that the server has disabled, you'll also get this error (which is what my VS was doing). The registry edits described here worked for me:

    https://support.microsoft.com/en-us/help/3206898/enabling-iis-manager-and-web-deploy-after-disabling-ssl3-and-tls-1-0

  • Re: The underlying connection was closed: An unexpected error occurred on a send.

    Jan 09, 2020 10:47 PM|bvj|LINK

    Excellent find, @tamtranthien