FP: Couldn’t close table! Dynamics GP Error Solution

I talked before in a previous blog post about the “syContentPageXMLCache cannot find table” error. This and its cousin the “FP: Couldn’t close table!” error are caused when something disrupts Dynamics GP’s long lived open SQL connections between the client and server.

FP: Couldn't close table! 

This might be due to networking issues like bad routing, changing drivers on network cards, intermittent physical faults with NIC cards, faulty Ethernet cables, faulty intermittent Ethernet sockets on walls when doors in that wall are slammed shut , servers or client machines going to sleep, server NIC card problems, connectivity problems (WIFI), firewall outages, or many other potential causes. However there is always a break in communication between the server and client, just finding the root cause can be tricky.

My long standing problem

I found myself involved in this today. A new employee started, since they have been working for us, every time the Dynamics GP application is closed at the end of the day (or even mid way through the day), the application generates the “FP Couldn’t close table” error. They have also been getting other SQL related errors such as syContentPageXMLCache cannot find tableor “Invalid object name ‘##1470453’” – for reference, the latter is a temp table dropped when the connection dropped.

IT support had already tried:

  • New GP user ID for the user
  • Rebuilding the PC from the standard image
  • Swapping the newer PC hardware the new user got, for the same hardware the rest of the users are using, involving another new image rebuild.
  • Deleting the user’s AD profile and rebuilding it.
  • Swapping the Ethernet cables
  • Swapping to another wall port of a user that is known to work, also on another network switch
  • Checking power saving sleep options on the NIC and PC

None of the above has stopped the issue occurring. It came to a head when a quotation was entered, that ended up pulling the wrong currency for pricing. I suspect the SQL connection broke under the hood during the session. I was stumped as to what could possibly be causing the connection outages bearing in mind what had already been tried.

Attempting to resolve the issue

The user was instructed to email me the screenshots of the errors, the second they happened. Not long after, I came back from my lunch to see an email come in. Attached was the stereotypical errors caused by connection loss,” FP: Couldn’t close table!” error dialog.

I connected to the event log on the offending machine, looked at recent history and found the problem.

Event viewer shows Kernel Power event shortly before problem

The power settings in Windows 10 were checked and they all looked ok from the top level screen, set to sleep “Never”.

Power Options window

However when drilling into “Change advanced power settings” and checking through all the options, the “Allow hybrid sleep” setting was set to ON. Looking at the other machines in the area, they all were set to OFF.

Advanced power settings

So my current working assumption is that the user had come back from lunch, during which time the machine had snoozed, causing the SQL connection to drop, with the following errors on resuming using GP:

An unknown SQL error occurred.

A SQL network connection error occurred and your connection was cleared.

 

[Updated from original post]

A few days later…

The user experienced the issue again, the  fix had not worked. I did some more research and found some people reporting that although the advanced power settings are set to "never", sometimes by setting them to a very large number of minutes, then later setting back to “never” works. Almost as if the setting has not properly taken.

I updated the machine to have an 18 hour sleep time, to see what happened the next day.

There were also reports of overheating CPUs causing machines to sleep, but this user's machine hardware had been changed before, so I ignored that possibility.

Following day…

First thing in the morning I saw the user go for a coffee, this reminded me to go look at the machine log, but I couldn’t connect or "ping" the machine. On visiting the machine I found it asleep, this is when it dawned on me that what we were seeing may be a "machine-chair interface" issue.

I woke the machine with the mouse, checked the log to see it had gone to sleep moments before the user had gone for coffee. This time frame was too short for any reasonable timeout to have occurred, as the machine would be sleeping every few moments surely? The machine log had previously shown a pattern of sleeps at lunchtime and morning and mid afternoon. I had been assuming these sleeps were the user’s breaks due to some kind of inactivity timeout.

On the user returning from coffee I enquired about how they lock the machine when leaving it (note that our staff handbook mandates machines be locked when unattended). The user then showed me how they lock the machine…

user selects sleep menu

...the user selects the sleep menu!

Goodness knows how much time had been wasted tracking this down, but my recommendation might be now that we disable sleep for desktop machines in group policy!

So it turns out that the user was manually putting the machine to sleep so as to “lock it” each time they went for a break, thus causing the Dynamics GP database connection to break as the network card would be off and causing havoc with the application. The user had not made any association in the discussions at their desk about how we are stumped as to why the machine keeps sleeping and the action of what they saw as “locking” it. This is where being able to stand next to a user to observe an issue can be so valuable in problem solving!

Needless to say we have had no further issues since showing the user how the [Windows]+L key locks the machine.

Further reading

David Musgrave has in the past posted some more information on these kinds of issues that are worth a read:

TCP Chimney Setting and SQL Server Error: TCP Provider: An existing connection was forcibly closed by the remote host

More on SQL Server Connection issues with Microsoft Dynamics GP

Create ASP.NET virtual directories in IIS Express using windows credentials to another server (website project)

Moving from developing ASP.NET sites against the full IIS to IIS Express led me to migrating the many virtual directories that were defined for the site. There was an added dimension to the problem, in that the the virtual directories map to central development resources server to keep the many GB of images and tens of thousands of pdf files off the developer SSD drives, for space reasons (and sanity).

To my relief it turns out to be totally possible for website projects (as oppose to website application projects), but I didn’t on performing a quick internet search, find any reference to credentials.

The virtual directories can be set up as part of the site definition in the .vs folder within the applicationhost.config of the website solution. By editing that file, under the following node:

<site
  <application path= …
      <virtualDirectory path= …

Luckily rather than in notepad, I opened up this file in Visual Studio, and found intellisense gave me the answer I had been looking for, and it was a good one!

virtualdirectory

You can see there are userName and password attributes available.

So add a virtualDirectory node for each virtual directory, following this pattern, one after another, after the application node.

<virtualDirectory path="/imageitems" physicalPath="\\resServer\Resources\ProdRes"  
userName="devaccess@mydomain.net" password="ourpassword123" />

We use a read only, low rights user for this, so I’m not too bothered about the password getting into the config file.

Convert ASP.NET “Website Project” from IIS to IIS Express

I had this problem to solve and thought I’d document my solution here, as I didn’t find anything appropriate documented when I tried searching the search engines.

Website Project vs Website Application Project

There are two broad ways ASP.NET websites can be setup as applications.

  • Web site projects
  • Web site application projects

The quickest way to tell the difference is that an application project uses a visual studio project file to define the files that are in the project, whereas for a web site project, any file under the folder is classed as part of the project.

For more information look at: Web Application Projects versus Web Site Projects in Visual Studio (msdn)

Web site projects are opened by going to File->Open Website, rather than File->Open Project, obviously there are many ways to open projects.

I labour this point as on the forums it is almost the norm for questions about website projects get people answering as if it were a website application project, understandable as that is the form of project most developers will experience.

Finally I decided to tackle the problem of being required to have local administrator rights to develop with IIS hosted sites. Running with local admin rights in this day and age is becoming more and more risky and something that is getting less and less necessary so long as you have an alternative elevated user to use when the need arises to perform operations that require it (like installing software). 

These days developing sites against IIS Express is the norm, back in the day we outgrew Cassini, a small developer webserver that used to host sites, as we had url rewriting, host headers, custom url rewrite modules, virtual folders mapped with custom credentials etc. It turns out that now in 2017 all this is possible using IIS Express. How do you move the site though?

These are the steps I performed that worked for me:

Remove the IIS website

In IIS manager I removed the website, so IIS is no longer managing that folder.

Edit the solution file

I edited the solution file to remove the website project definition node from it.

Add the website back in

I then opened the solution and used the add existing website option to add the website folder from source control back into the solution.

Define virtual directories

I then edited the applicationhost.config file that resides in the solution .vs folder, defining the virtual directories that were previously defined in IIS. I did this under the <virtualDirectory path= section for the site.

Added https binding

I added a binding to the <bindings> section for https,
<binding protocol="https" bindingInformation="*:44340:localhost" />

Custom rewriting 

The custom URL rewriter and rewrite rules seemed to come over by themselves so no action was needed.

Custom Host name

I followed the instructions on USING A CUSTOM HOSTNAME WITH IIS EXPRESS AND VISUAL STUDIO 2015 (VS2015)

to get the custom hostname so the site responds to custom host headers correctly.

<binding protocol=”http” bindingInformation=”*:80:mywebapp.127.0.0.1.xip.io” />

Success

I was then amazed to see the site come up first time on rebuilding it and launching it.

Installing Dynamics GP Intrastat Module

If you are looking for the Intrastat module, it is part of the Main GP install, I think fromGP2013 when more of the product extras were bundled in - but certainly from GP 2015. When running the GP installer the various features that can be installed are offered in the installer, find Enhanced Intrastat, click on the icon to change if it is installed or not by the installer. This can also be performed retrospectively to add the feature to an existing install.

intrastat installer Dynamics GP

You must switch the module on in company options and use the intrastat setup window to get it going. Look for the user guide on line or on the installation media for full details.