Page 1 of 1

How to truly test that your VL Web page is connected

Posted: Tue Aug 01, 2017 5:13 am
by dhnaigles
I have tried to use #sys_web.online to determine if my device is connected to the internet and, therefore, connected to my application server. This does not always provide a valid response and my web page becomes unresponsive due to the attempt to use a server module that is no longer available.

The documentation says: "While this may be a useful tool, the only true test of whether a browser can communicate with the server is to attempt to access the server."
How are you suppose to attempt to access the server if you are offline? Any sample would be most appreciated.

Re: How to truly test that your VL Web page is connected

Posted: Tue Aug 01, 2017 5:39 am
by jyoung
Could you create a status server module that just sends an OK status code back?

Code: Select all

srvroutine name(CheckStatus)
field_map for(*OUTPUT) class(#wk_Status) parameter_name(Status)

#wk_Status := OK
endroutine
Then you could use ExecuteAsync to get completed or failed events

Code: Select all

define_com class(#CheckStatusServerModule.CheckStatus) name(#CheckStatus)

mthroutine name(CheckServerStatus)
#CheckStatus.ExecuteAsync status(#wk_Status)
endroutine

evtroutine handling(#CheckStatus.Completed)
* connected to the server all is good
endroutine

evtroutine handling(#CheckStatus.Failed) handled(#handled) reason(#reason)
* could not connect to the server check reason, likely SERVERERROR

* don't kill the whole app
#handled := True 
endroutine
- Joe

Re: How to truly test that your VL Web page is connected

Posted: Wed Aug 02, 2017 2:12 am
by dhnaigles
Thank you very much for this solution. It will work, but I wonder if we could not get a "supported" solution from LPC. Checking for server connectivity is inherent in web applications. Why could LPC not delivery a predesigned reusable part (as an ancestor) along with its associated server module that would return a property of "Connected" or "Online"?

Re: How to truly test that your VL Web page is connected

Posted: Wed Aug 02, 2017 10:35 am
by dannyoorburg
Hi,

personally I just use #SYS_WEB.Online to indicate connectivity, and that's enough for me. The user is on a device that's somehow connected.

After that there is still a (small) chance that ANY ServerRoutine call can fail somewhere during execution, you just got to make sure you handle the individual failed events (or the generic #SYS_WEB.RequestFailed) gracefully.

Danny

Re: How to truly test that your VL Web page is connected

Posted: Thu Aug 03, 2017 12:23 am
by dhnaigles
Danny
I tried to use #sys_web.online when I was first connected and then I disconnected (turned off my VPN and lost all connectivity to the server. #sys_web.online remained TRUE. Not a good situation, especially for truck drivers on tablets.

My test is to determine if i can refresh my server data from my local storage. I would rather have it say that the tablet is offline than to try and retrieve data from the server. My server routine is just a return code. It runs on a timer and works perfectly.