West Wind Internet and Client Tools
wwwjsonserializer Error
Gravatar is a globally recognized avatar based on your email address. wwwjsonserializer Error
  Roger Bradshaw
  All
  Mar 5, 2019 @ 11:41am

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.

Gravatar is a globally recognized avatar based on your email address. re: wwwjsonserializer Error
  Rick Strahl
  Roger Bradshaw
  Mar 5, 2019 @ 12:17pm

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 ---

Gravatar is a globally recognized avatar based on your email address. re: wwwjsonserializer Error
  Roger Bradshaw
  Rick Strahl
  Mar 6, 2019 @ 09:24am

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%...

Gravatar is a globally recognized avatar based on your email address. re: wwwjsonserializer Error
  Rick Strahl
  Roger Bradshaw
  Mar 6, 2019 @ 02:42pm

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 ---

Gravatar is a globally recognized avatar based on your email address. re: wwwjsonserializer Error
  Roger Bradshaw
  Rick Strahl
  Mar 7, 2019 @ 05:04am

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)

Gravatar is a globally recognized avatar based on your email address. re: wwwjsonserializer Error
  Roger Bradshaw
  Tore Bleken
  Mar 7, 2019 @ 08:21am

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.

Gravatar is a globally recognized avatar based on your email address. re: wwwjsonserializer Error
  Rick Strahl
  Roger Bradshaw
  Mar 7, 2019 @ 12:17pm

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 ---

Gravatar is a globally recognized avatar based on your email address. re: wwwjsonserializer Error
  Roger Bradshaw
  Rick Strahl
  Mar 7, 2019 @ 01:30pm

Excellent point. This makes total sense - thanks.

Gravatar is a globally recognized avatar based on your email address. re: wwwjsonserializer Error
  Rick Strahl
  Tore Bleken
  Mar 7, 2019 @ 09:51pm

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 ---

© 1996-2024