Hi Rick,
We recently had an unplanned SQL failover. At 3am. Of course. As you might recall I have my WWC app configured to use SQL for wwsession & wwrequestlog. Once the HA/AG cluster had recovered, we still had app login issues because the COM server connections for my WWC app were still trying to use the SQL handle established the last time the COM servers were spun up. This resulted in calls to r/w wwsession & wwrequestlog failing.
When I came online I figured out pretty quickly that I just needed to cycle the servers which restored order to my universe. The question that has been raised by my DevOps folk is, is there a way to script/automate that? Something like calling ToggleMessagingMode.wc twice (switch to File, switch back to COM) comes to my mind but authorized credentials are necessary in order to access the administration.wc page. Is there a way to programmatically log in to that? Or is there a different strategy you'd recommend that doesn't require me or someone from my team to be on call in the middle of the night. Of course, rebooting the servers will also do the trick but that could take a bit more time than the mode toggle approach.
TIA
Hmmm... if the handle is bad, the connection should end up releasing and retrying a new connection on the next request.
The Error method has this code inside of it that should restart the connection on connection failures:
DO CASE
*** Invalid Connection Handle
CASE nError = 1466 AND THIS.nerrorno <> 1466
THIS.nerrorno = 1466
THIS.cerrormsg = MESSAGE()
IF THIS.Connect(THIS.cconnectstring)
THIS.lerror = .F.
THIS.nerrorno = 1466 && So we can trap 'recursive' errors above
THIS.cerrormsg = ""
RETRY
ENDIF
ENDCASE
If you have error logging perhaps you can see what the FoxPro error was that occurs on the failure.
+++ Rick ---
I'm seeing a bunch of messages like this in wcTracelog.txt (see below) during the time things were not happy. Unfortunately, I don't have much else that looks useful. One other bit I didn't share before is that for users the behavior was the login page came up fine. It would simply return to the login page after entering user and pw. My assumption was that was because it could not generate proper tokens/ etc from wwSession because of the borked SQL connection.
Just to be clear, you are saying that the server object will attempt to get a valid connection to its wwsession/wwrequestlog DB when the errorcode returned is 1466?
08/23/2026 03:59 AM - Processing Error -
<pre>
Error: 103
Message: Allowed DO nesting or expression evaluation level exceeded.
Details:
Code: DECLARE INTEGER GetIDispatch IN (m.__VFP2C_FLL_FILENAME) OBJECT
Program: getuser
Line No: 332
Handled by: Rfc3server.OnError()<br>
</pre>
08/23/2026 04:00 AM - Processing Error -
<pre>
Error: 103
Message: Allowed DO nesting or expression evaluation level exceeded.
Details:
Code: DECLARE INTEGER GetIDispatch IN (m.__VFP2C_FLL_FILENAME) OBJECT
Program: getuser
Line No: 332
Handled by: Rfc3server.OnError()<br>
</pre>
08/23/2026 04:00 AM - Processing Error -
<pre>
Error: 1925
Message: Unknown member ODATA.
Details: ODATA
Code: DECLARE INTEGER GetIDispatch IN (m.__VFP2C_FLL_FILENAME) OBJECT
Program: getsessionvar
Line No: 445
Handled by: Rfc3server.OnError()<br>
</pre>
08/23/2026 04:00 AM - Processing Error -
<pre>
Error: 1925
Message: Unknown member ODATA.
Details: ODATA
Code: DECLARE INTEGER GetIDispatch IN (m.__VFP2C_FLL_FILENAME) OBJECT
Program: getsessionvar
Line No: 445
Handled by: Rfc3server.OnError()<br>
</pre>
08/23/2026 04:00 AM - Processing Error -
<pre>
Error: 1925
Message: Unknown member ODATA.
Details: ODATA
Code: DECLARE INTEGER GetIDispatch IN (m.__VFP2C_FLL_FILENAME) OBJECT
Program: getsessionvar
Line No: 445
Handled by: Rfc3server.OnError()<br>
</pre>
That FLL name is not part of Web Connection so that must be some customization. I suspect you're using custom custom de/encryption in the GetUser() method that's failing?
+++ Rick ---
It's a VFP library (VFPx VFP2C32) written by a fellow named Christian Ehlscheid with an apparent assist from the estimable Eric Selje. (There's quite a bit of overlap between this library and what you've done with WWC.) According to its description:
VFP2C32 (acronym for "VFP to C 32 bit") is a bridge between Visual Foxpro and the C programming language. Additionally it contains wrappers around many windows api functions.
Checking my implementation there is a single SET LIBRARY TO call in the OnLoad of my server object after initializing the oBridge object. I'm not seeing any explicit calls to any functions from that library in the UserSec.GetUser methods. I am using the framework defaults for encryption/hashing.
My gut is it's a misdirect from the VFP error handler but we'll see.
Either way, I think the end result is for whatever reason, the engine didn't know the SQL handle for wwsession/wwrequestlog was invalid, and it was necessary to toggle to file mode and back to get it to establish a valid handle. It's a plausible theory based on observation but I can't prove or disprove.
You shouldn't have to switch into file mode and back. Use Unload Servers - the SQL connection reconnects when the server starts back up.
+++ Rick ---
Thanks. In the case of manually unloading it's just an extra click or two. I have vague memories that in the past I had to do that double switch because there were orphaned file instances. But now that I think about it I don't think I've seen that since you re-architected the plumbing. Which brings me back to the original question; is there a way to script a call to ReleaseComServers.wc?
Sure. It's just an authenticated Http call.
Use loHttp.Get()
LOCAL loHttp as wwHttp
loHttp = CREATEOBJECT("wwHttp")
IF !EMPTY(lcUsernameHttp)
loHttp.cUsername = lcUsernameHttp
loHttp.cPassword = lcPasswordHttp
ENDIF
loHttp.Get("https://yoursite.com/ReleaseComServers.wc") && or `LoadComServers.wc`
+++ Rick ---
Sorry, if I wasn't clear. I was thinking more from the POV of a DevOps person who needs to recycle the servers. So some other nerd equivalent like Postman or curl, but it also has to able supply the secret auth sauce.
Uhm, just use Postman or a script with Curl or Powershell's http client? Auth is Windows Auth. Not sure how Postman supports this off the top of my head, but it probably does.
+++ Rick ---