Web Service Proxy Generator
an existing connection was forcibly closed by the remote host
Gravatar is a globally recognized avatar based on your email address. an existing connection was forcibly closed by the remote host
  scrapdragon
  All
  Oct 22, 2018 @ 01:47pm

I have a VFP application that was generated using version 1.28 Of the .NET Web Service Proxy Generator and has been working perfectly for about 5 years. Recently, the web service was moved to a new URL and now I am getting the error 'an existing connection was forcibly closed by the remote host' when trying to log in. The application still works on the old production site, as well as their sandbox site, but not on the new production site. I thought the problem might be with TLS 1.2, but they claim that the sandbox only uses TLS 1.2. I am not able to regenerate the application using ver 1.28 because it was downloaded and installed on a laptop that will no longer boot.

I tried using the demo of version 1.60 but the proxy generation fails as follows: West Wind Web Service Proxy Generator


Service Generation failed: WSDL Parsing Error: Microsoft (R) Web Services Description Language Utility [Microsoft (R) .NET Framework, Version 4.0.30319.18020] Copyright (C) Microsoft Corporation. All rights reserved. Error: There was an error processing 'https://w2api.leadsonline.com/leads/ws/scrap/ticketscrapws.asmx?WSDL'.

  • There was an error downloading 'https://w2api.leadsonline.com/leads/ws/scrap/ticketscrapws.asmx?WSDL'.
  • 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 If you would like more help, please type "wsdl /?".


I am able to generate a proxy to the old URL 'https://www.leadsonline.com/leads/ws/scrap/ticketscrapws.asmx'.

Gravatar is a globally recognized avatar based on your email address. re: an existing connection was forcibly closed by the remote host
  Rick Strahl
  scrapdragon
  Oct 22, 2018 @ 03:43pm

I would still suspect TLS 1.2 with this.

What version of Windows are you using? And you are on the latest version of the proxy generator right?

There's more info on the TLS 1.2 issues here: https://www.west-wind.com/wconnect/weblog/ShowEntry.blog?id=937

Check that out and then report back what applies to you.

Bottom line:

  • Old versions of Windows require registry tweaks
  • Windows XP and Vista don't support TLS 1.2
  • Old versions of .NET require explicit code support

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: an existing connection was forcibly closed by the remote host
  Rick Strahl
  Rick Strahl
  Oct 22, 2018 @ 03:46pm

In addition to TLS 1.2 issues you should also make sure that a) you can reach the service URL with your browser.

Make sure that the Proxy Generator has port access - a closed connection usually means that something is blocking the connection - Either a bad TLS connection or something like a firewall blocking the outbound traffic. You can try temporarily disabling the firewall to see the request goes through and if it does turn it back on and add an exception for the proxy generator and likely your application that will end up using the service.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: an existing connection was forcibly closed by the remote host
  scrapdragon
  Rick Strahl
  Oct 22, 2018 @ 04:34pm

Rick, I am on windows 8.1 which is supposed to have TLS 1.2 built in. I can open the URL in my browser and also when I enter the URL in the proxy generator it resolves. I don't get the error message until I click on Generate. I have used Notepad ++ to compare the two xml wsdl definitions and there is no difference except the 'www' in one and the 'w2api' in the other. I disabled my Norton smart firewall and still get the error on attempting to generate. Can you try generating a proxy for this URL to see if you get the same error?

Also, the web service vendor suggested setting my certificate validation to ignore errors and provided this code:

            ServicePointManager.ServerCertificateValidationCallback =
                new RemoteCertificateValidationCallback(
                    delegate (
                        object sender2,
                        X509Certificate certificate,
                        X509Chain chain,
                        SslPolicyErrors sslPolicyErrors)
                    {
                        return true;
                    });
Gravatar is a globally recognized avatar based on your email address. re: an existing connection was forcibly closed by the remote host
  Rick Strahl
  scrapdragon
  Oct 24, 2018 @ 12:06am

I tried your service here and it worked without problems (at least generating it). So I suspect the issue is that something is either blocking or you have issues with TLS 1.2.

Just to be sure download the latest version - I just updated it again to make sure the very latest of all the tools are there. I also updated the WSDL generator to the 4.62 version of .NET (rather than the older 4.5 version which may or may not have the TLS 1.2 fix applied - given that it did work before I updated I supect it does, but using the 4.62 version will make sure).

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: an existing connection was forcibly closed by the remote host
  scrapdragon
  Rick Strahl
  Oct 24, 2018 @ 01:11pm

I was able to get the v 1.60 proxy to generate by adding these two lines to my registry.

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework\v4.0.30319] "SchUseStrongCrypto"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft.NETFramework\v4.0.30319] "SchUseStrongCrypto"=dword:00000001

The registry entries didn't resolve the error in my application which was generated with version 1.28. I will try to see if I can get it to work with the 1.60 proxy code.

Gravatar is a globally recognized avatar based on your email address. re: an existing connection was forcibly closed by the remote host
  Rick Strahl
  scrapdragon
  Oct 24, 2018 @ 01:20pm

The issue isn't so much that it was generated with 1.28, but if you're using the old wwDotnetBridge.dll it will not have automatically set the TLS 1.2 flag. If you use the newer DLL it'll most likely work.

Where did you find a reference to those keys - I can see that helping but wasn't aware that this was an issue. That might be another short cut to the setting the TLS related keys in the registry for Windows 7 and 8 (original).

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: an existing connection was forcibly closed by the remote host
  scrapdragon
  Rick Strahl
  Nov 6, 2018 @ 01:39pm

The registry entries were found by one of the programmers in my shop when he was trying to get the c#/.NET version of our software to access the same web service. I downloaded version 1.62 of the generator, and regenerated a proxy. Using my same code as before, it fails to create an instance using this code:

DO ticketScrapWSproxy
loProxy = CREATEOBJECT("ticketScrapWSProxy","V4")

do wwDotNetBridge
LOCAL loBridge as wwDotNetBridge
loBridge = CREATEOBJECT("wwDotNetBridge")

LOCAL loItem as Westwind.WebConnection.LoginInfo
loItem = loBridge.CreateInstance("ticketScrapWSProxy.LoginInfo")

loItem.storeId=ALLTRIM(storeid)
loItem.username=ALLTRIM(username)
loItem.password=ALLTRIM(pwd)

The proxy code that uses LoginInfo looks like this:

************************************************************************
*  CheckLogin
****************************************
FUNCTION CheckLogin(login as LoginInfo) as Response
LOCAL loException as Exception, lvResult as Response

THIS.lError = .F.
this.cErrorMsg = ""

lvResult = .F.
TRY	
	lvResult = this.oBridge.InvokeMethod(this.oService, "CheckLogin", login)
	
CATCH to loException
	THIS.GetErrorDetail(loException)
ENDTRY

RETURN lvResult
ENDFUNC
*   CheckLogin

When this didn't work, I followed your suggestion and used the proxy that I generated with version 1.28 and the version 1.62 wwdotnetbridge.dll and it did work on the TLS 1.2 site, which is good.

However, I have another app that accesses a web service that we wrote to verify the users software license. When that runs with the 1.62 wwdotnetbridge.dll I get the message:

"Unable to load wwDotNetBridge; Unable to load Clr Instance. The assembly is built with a runtime newer than the currently loaded runtime and cannot be loaded."

What do I need to do to get rid of this error?

Gravatar is a globally recognized avatar based on your email address. re: an existing connection was forcibly closed by the remote host
  Rick Strahl
  scrapdragon
  Nov 6, 2018 @ 03:40pm

The newer DLL is built with .NET 4.52 so you need to have at least that version installed in order for the code to run. The Wizard uses that version of wsdl.exe as well so you will need to make sure that this version of .NET (or later) is installed on any machine running this. You also need to make sure you're not using V2 in the version parameter (if you have an old proxy generated version that might be the case).

Note that Windows Vista and XP can't run .NET 4.5. Only Windows 7 forward is capable of running .NET 4.52 (and it'll likely be installed on those anyway via Windows update if the machine is reasonably up to date).

+++ Rick ---

© 1996-2018