Web Connection
How to debug when my Webconnection stops responding to web requests
Gravatar is a globally recognized avatar based on your email address. How to debug when my Webconnection stops responding to web requests
  Chris Jewell
  All
  Oct 16, 2020 @ 07:06am

Hi All,

Recently I've started to notice occasionally that my web connection app stops responding to web requests, the app itself is running and has no errors. If I restart the WC app, the web request is processed as expected.

I'm in the development phase of my WC app & I'm working on a dev server and also I'm running my WC App within VFP IDE (not runtime). I do not have to restart IIS or my browser just the WC app.

It is highly likely it is something I'm doing that is upsetting the apple cart, especially considering WC is used widely without this issue.

As there are no error messages I'm unsure where to start, any advice would be much appreciated?

Cheers, Chris

Gravatar is a globally recognized avatar based on your email address. re: How to debug when my Webconnection stops responding to web requests
  Michael B
  Chris Jewell
  Oct 16, 2020 @ 07:23am

I have this issue occur fairly frequently when a bot is pounding on a site. There are no hard errors in the wwrequestlog but often I will discover errors in wcerrors.txt (timeouts or com errors).

Are you using wc.dll or the .net managed handler? Rick will tell you the latter is more stable.

Gravatar is a globally recognized avatar based on your email address. re: How to debug when my Webconnection stops responding to web requests
  Rick Strahl
  Chris Jewell
  Oct 16, 2020 @ 07:56pm

You're going to have to be a little more specific on what happens there exactly.

If you're in the development environment - the FoxPro server is still running and there are no error dialogs or open file dialogs etc? If that happens can you check your status settings on the still running server and ensure that the paths and timeouts etc. still look OK?

Could it be a path problem? Your application perhaps changes paths and so loses access to the relative Temp path? Check the path that the application is running under.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: How to debug when my Webconnection stops responding to web requests
  Chris Jewell
  Michael B
  Oct 19, 2020 @ 02:16pm

Hi Michael\Rick,

Thanks for your responses, taking what you both mentioned, please see my findings below :

Once my WebApp stops responding, I can see the .tmp web request file sitting in the .\temp\ folder, after a minute or so, this file disappears and the file wcerrors.txt then appears, this file contains the following text : 2020-10-19 21:23:31.244 - 11_5898f1cc - File request timed out. - /WCGateway/ProjectsView.wc?Key=10544

Then, within the WebApp I can see the current directory is correct: \WEBCONNECTIONPROJECTS\WCGATEWAY\DEPLOY\ (and this folder contains the \TEMP\ folder mentioned above).

In regards to the handler, I'm not sure tbh, I think I'm using the wc.dll, I've not looked at the .NET option, although with 'Web Request Data Trace' turned on (within WC.INI) I can see the following line on all my web pages: DLLVERSION=Web Connection 7.04 (.NET Handler) So, maybe it is using the .NET handler, sorry I'm still getting to grips with web development!

I'm going to try and find a way to replicate the issue, as at the moment it is a bit random and only seems to happen when the WebApp is inactive for 5 to 10 minutes.

If you have any other suggestions please let me know? and I'll update this thread if I find anything useful.

Cheers, Chris

Gravatar is a globally recognized avatar based on your email address. re: How to debug when my Webconnection stops responding to web requests
  Rick Strahl
  Chris Jewell
  Oct 19, 2020 @ 02:26pm

How are you running the application?

IIS will unload an application if it's idle for 20 minutes by default. After that the app will be reloaded meaning it will take longer to reload. If you are launching your servers with the application perhaps there's an issue with how the auto-start servers are launching (or rather not re-launching after the app was shut down). You can check this out by explicitly stopping IIS and restarting it and seeing if your application keeps on running.

Again - not enough information to really help you.

We need to know how you are running the application: Dev/production, COM/File mode, Autostart settings...

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: How to debug when my Webconnection stops responding to web requests
  Michael B
  Chris Jewell
  Oct 19, 2020 @ 03:31pm

Chris,

When you say you have to 'restart the wc app' are you running in 'file mode' or 'com'? If you are running in COM most problems occur when your file permissions are not properly setup.

It would be a good idea to check the servers event logs for clues. In my experience, when my exe hangs there are obvious errors in the event log that point to wc.dll.

ps: The fact that you see 'managed handler' means you are in fact using the .net version (this is preferred) - Maybe you should start by downloading the latest and greatest version of WWWC so that you are sure to get latest dll's. You could be having some TLS issues and the version of .net you are running may be older or newer than the WWWC dll's.

Gravatar is a globally recognized avatar based on your email address. re: How to debug when my Webconnection stops responding to web requests
  Michael B
  Michael B
  Oct 19, 2020 @ 03:51pm

One more comment. As you are developing your app, make sure that Foxpro is running 'as administrator'. That first hit might be able to 'sneak through' then the OS shuts it down. Also, I cannot help but wonder if you have an exe running in COM mode and your app running inside the IDE as you mentioned. This could be why the first hit works.

I have seen orphaned exe's running on my dev machine due to how my ini file was setup at the time.

It's best to learn how to use the framework with Rick's examples workng, by adding your own methods to it and then debugging from the top calling program to see how things work from the inside. It took me many years to have the courage to do that... I am on year 22 now of using the framework and still going strong!

Gravatar is a globally recognized avatar based on your email address. re: How to debug when my Webconnection stops responding to web requests
  Rick Strahl
  Chris Jewell
  Oct 19, 2020 @ 05:49pm

I suspect the problem is that you start your application interactively, and it runs on the desktop. It works until IIS shuts it down after the 20 minute default idle timeout. If autostartservers is turned on that will kill the EXE and then it probably can't restart because you either haven't configured the right server EXE or because there's a permissions issue.

The settings are in web.config in the Web Folder.

web.config settings

Specifically you'll need to look at:

  • AutoStartServers - number of server instances that automatically launch. If true EXEs or COM Servers are killed on shutdown.
  • ServerCount - determines how many servers are launched
  • ComServerProgId - If running in COM mode this is the server that gets loaded (ie. MyApp.MyAppServer)
  • ExeFile - If running in File Mode this will be the EXE that is launched on startup

If you're running in debug only you'll want to have AutoStartServers off and run in File mode.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: How to debug when my Webconnection stops responding to web requests
  Chris Jewell
  Rick Strahl
  Oct 21, 2020 @ 07:48am

Hi Michael and Rick, Thank you both for all your help & advice.

I think Rick is on the right track regarding IIS shutting down the worker after 20mins, it does seem to be at this point the WebApp no longer processes Web Requests. I can also see this in the Event Viewer:

A worker process with process id of '13140' serving application pool 'West Wind Web Connection' was shutdown due to inactivity.  Application Pool timeout configuration was set to 20 minutes.  A new worker process will be started when needed.

I've tried setting the worker timeout to 0, meaning it should not terminate after 20mins and keep running indefinitely, but the issue still persists.

I do run my VFP IDE in administrator mode.

I suspect I need to try the different running modes to see if any specific setup improves stability.

I'm not quite sure how to answer your questions regarding my current setup, so please see my WCGateway.ini and Web.Config file contents below, hopefully, these will help answer your questions?

WCGateway.ini contents :

[Main]
TempFilePath=.\temp\
Template=WC_
TimerInterval=100
ScriptMode=1
DebugMode=Off

HomeUrl=https://www.wd4g.com/WCGateway/WDLogin.wc

showrequestdata=Off
showserverform=On
showstatus=On
saverequestfiles=Off

COMReleaseUrl=https://www.wd4g.com/WCGateway/ReleaseComServers.wc
UnattendedComMode=On
Memusage=8176

Adminemail=
Adminmailpassword=
Adminmailserver=localhost
Adminmailusername=
Adminmailusessl=Off
Adminsenderroremail=Off

# wwPdfPrinterDriver Windows 10, Server 2016
Postscriptpdfprinterdriver=Microsoft Print to PDF
# Ghostscript
# Postscriptpdfprinterdriver=Xerox PS Class Driver
Applicationname=West Wind Web Connection
Deploymentmode=Production
Sqlconnectstring=
Systemfilesdatapath=
Version=1.0
Logtofile=Off
Markdownpagesanitized=On
Showdesktopform=Off
Pageparsemode=1



[ServerConfig]
Virtual=WCGateway
ScriptMaps=wc,wcs,md,wc
IISPath=IIS://localhost/w3svc/1/root

[Wcgatewayprocess]
Datapath=
Htmlpagepath=c:\WebConnectionProjects\WCGateway\Web\
Virtualpath=/WCGateway/
[Wwmaint]
Datapath=.\
Htmlpagepath=c:\WebConnectionProjects\WCGateway\Web\
Virtualpath=/WCGateway/

Web.Config contents:

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="webConnectionConfiguration" type="System.Configuration.NameValueSectionHandler,System,Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <section name="webConnectionVisualStudio" type="System.Configuration.NameValueSectionHandler,System,Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </configSections>
  <appSettings>
    <add key="enableSimpleMembership" value="false" />
  </appSettings>
  <webConnectionConfiguration>
    <!-- NOTE: These settings apply only to the Web Connection Managed Module! -->
    <add key="MessagingMechanism" value="File" />
    <add key="Timeout" value="90" />
    <add key="TempPath" value="~\..\deploy\temp\" />
    <add key="TempFilePrefix" value="WC_" />
    <add key="ComServerProgId" value="Wcgateway.WcgatewayServer" />
    <add key="ComServerLoadingMode" value="LoadBased" />
    <add key="ServerCount" value="2" />
    <add key="AutoStartServers" value="False" />
    <add key="ExeFile" value="~\..\deploy\Wcgateway.exe" />
    <add key="UpdateFile" value="~\..\deploy\Wcgateway_Update.exe" />
    <add key="AdminAccount" value="ANY" />
    <add key="AdminPage" value="/admin/admin.aspx" />
    <add key="LogDetail" value="False" />
    <add key="ValidateRequest" value="False" />
    <add key="MessageDisplayFooter" value="Generated by Web Connection IIS .NET Connector Module" />
    <add key="UseStaComServers" value="False" />
    <add key="UseCustomManifestLoading" value="False" />
    <add key="AuthenticationMode" value="Default" />
    <add key="PassAspNetContext" value="False" />
  </webConnectionConfiguration>
  <webConnectionVisualStudio>
    <!-- Configuration Settings for the Web Connection Visual Studio Add-in 
       Not used at runtime, only at the design time -->
    <add key="FoxProjectBasePath" value="c:\WebConnectionProjects\WCGateway\deploy\" />
    <add key="WebProjectBasePath" value="c:\WebConnectionProjects\WCGateway\Web\" />
    <add key="WebProjectVirtual" value="http://localhost/WCGateway" />
    <!-- Optional PRG launched when VFP IDE launches -->
    <add key="IdeOnLoadPrg" value="" />
    <!-- The editor used to edit FoxPro code - blank means FoxPro Editor is used -->
    <add key="FoxProEditorAlternate" value="%LocalAppData%\Programs\Microsoft VS Code\Code.exe" />
  </webConnectionVisualStudio>
  <system.web>
    <compilation defaultLanguage="c#" debug="true" targetFramework="4.0" />
    <!-- ASP.NET Request Limit Configuration for POST buffer and Script Timeout -->
    <httpRuntime maxRequestLength="10000000" executionTimeout="120" requestValidationMode="2.0" />
    <!-- Web Connection Managed Module requires that it runs in FULL TRUST (COM Interop) -->
    <trust level="Full" />
    <httpHandlers>
    </httpHandlers>
    <httpModules>
    </httpModules>
  </system.web>
  <!-- IIS 7 Script Map Configuration -->
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <!-- use this on IIS 7.5 and later to bypass IIS default Error handlers for failures -->
    <!-- httpErrors existingResponse="PassThrough" /-->
    <!-- IIS 7 Script Map Configuration -->
    <handlers>
      <add name=".wc_wconnect-module" path="*.wc" verb="*" type="Westwind.WebConnection.WebConnectionHandler,WebConnectionModule" preCondition="integratedMode" />
      <add name=".wcs_wconnect-module" path="*.wcs" verb="*" type="Westwind.WebConnection.WebConnectionHandler,WebConnectionModule" preCondition="integratedMode" />
      <add name=".md_wconnect-module" path="*.md" verb="*" type="Westwind.WebConnection.WebConnectionHandler,WebConnectionModule" preCondition="integratedMode" />
    </handlers>
    <defaultDocument>
      <files>
        <clear />
        <add value="default.wc" />
        <add value="Default.htm" />
        <add value="index.html" />
      </files>
    </defaultDocument>
    <!-- 
      EXTENSIONLESS URL HANDLING
      - Requires IIS Url Rewrite Module 2.0 (Web Platform Installer)

      matches any URLs that do not have a '.' in the path    
  -->
    <!--
    <rewrite>
      <rules>

        <rule name="Redirect to HTTPS" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="^OFF$" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}{URL}" redirectType="SeeOther" />
        </rule>

        <rule name="Extensionless Urls" patternSyntax="ECMAScript" stopProcessing="true">
          <match url="^((?!\.).)*$" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
          </conditions>
          <action type="Rewrite" url="UrlRewriteHandler.wc" appendQueryString="true" />
        </rule>

      </rules>
  </rewrite>
  -->
  </system.webServer>
</configuration>
Gravatar is a globally recognized avatar based on your email address. re: How to debug when my Webconnection stops responding to web requests
  Rick Strahl
  Chris Jewell
  Oct 21, 2020 @ 07:40pm

Not sure based on description. Files look fine and it doesn't look like you have auto-starting servers.

I'm not really clear on what your exact issue is.

If IIS is shutting down after 20 minutes, it will start back up when a new request comes in. If your server is running it will continue running - in theory the fact that the server has shut down should have no effect on your server.

Here's what I would do to check this out: Go into the Application Pool configuration in IIS and change the App Pool timeout to something like 3 minutes or so. Stop and restart the application pool. Start your FoxPro server and run your application make sure it works.

Then let it set for 4 minutes or so. You can check TaskManager and check for the w3wp.exe process (there may be more than one - one for each application pool that's active). Wait for that process to go away.

Check your FoxPro application and make sure it's still running. If not - well I'm not sure what in that case. Something is killing your app but it's not Web Connection unless the info you posted is not correct.

If it is still running, hit the Web site and hit a dynamic URL. The w3wp.exe process should start back up and the request should work just as it did before.

+++ Rick ---

© 1996-2020