I've moved my VFP application to 7.0 client tools. I've had several customers install my product with no issues. There is only 1 instance where a Win-10 customer is getting the error shown below. But, the error only occurs if they start up the application without an internet connection.
Hi Roger,
That error almost certainly means you're sending an empty string to the parser.
Before deserializing make sure you actually have a valid JSON string to process... if you say you have no internet connection you probably are trying to retrieve JSON from the Web and no connection, no JSON?
+++ Rick ---
So sorry to have bothered you with this one. I was convinced it wasn't this because 100% of my deserilization calls go through a wrapper that checks for this. Or, at least I thought it was 100%. Turns out it was 99.99%...
Not a problem 😃 that's what we're here for.
Maybe a better error message for that specific scenario (no data) would be useful.
+++ Rick ---
When I dug a little deeper into this, I discovered that the VFP function I use to check for an internet connection failed for this customer of mine. When he had a specific other application running on this PC without an internet connection, the function below failed and sensed that the computer was connected. I can't remember where I found this function, but I've used it for years and this is the first failure I've encountered. Do you have a suggestion for a better way to check?
FUNCTION TESTCONNECT
DECLARE INTEGER InternetGetConnectedState IN WinInet ;
INTEGER @lpdwFlags, INTEGER dwReserved
LOCAL lnFlags, lnReserved, lnSuccess
lnFlags=0
lnReserved=0
lnSuccess=InternetGetConnectedState(@lnFlags,lnReserved)
RETURN (lnSuccess=1)
DECLARE INTEGER InetIsOffline IN url INTEGER dwFlags
IF InetIsOffline(0) = 0
? "The local system is connected to the Internet."
ELSE
? "The local system is not currently connected to the Internet."
ENDIF
Reference: https://github.com/VFPX/Win32API/blob/master/samples/sample_322.md
Thanks for the suggestion. However, when I run this code from VFP, I get the indication I'm connected when I'm actually not connected.
In my experience those network detection routines are really worthless. They don't work in many situations if you have multiple network adapters or you have virtual networks, or virtual machines running on the same box etc. They're just not reliable...
Even if they did work it wouldn't account for failure to be able to reach a service - the service could be down and really that's usually what matters. The question is: Can I access this service I need data from?
IAC, the only reliable way to do this IMHO is to ping the actual site. You can do that with the any of the West Wind tools using this code:
DO wwhttp
loHttp = CREATEOBJECT("wwHttp")
llConnected = loHttp.HttpPing(2,"https://west-wind.com")
The number is the number of seconds to wait before the connection is considered timed out and failed.
+++ Rick ---
Excellent point. This makes total sense - thanks.
FWIW, that isn't working for me either. Neither does the dotnet version of this (which I thought was pretty reliable):
loBridge = GetwwDotnetBridge()
llOnline = loBridge.InvokeStaticMethod("System.Net.NetworkInformation.NetworkInterface","GetIsNetworkAvailable")
? llOnline
I think the reason in my case is that I have 4 network adapters configured (wired, wireless and two virtual adpaters for hyper-v and virtualbox). If I pull the wire neither the API call or the .NET routine reports the failure.
I still find it kind of odd that these functions fail because Windows accurately shows the broken network icon, but alas the functions do not report it properly.
I have seen this work though but like I said to Roger these APIs just aren't reliable and using an actual HTTP call to check is the best way to make sure what you're trying to call is actually reachable. That ensures not just the connection, but also the HTTP connection, the ISP and the remote site which is really all important to know on whether a connection is valid.
+++ Rick ---