How to truly test that your VL Web page is connected

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
dhnaigles
Posts: 56
Joined: Wed Feb 03, 2016 1:34 am
Location: Marlborough, MA, USA

How to truly test that your VL Web page is connected

Post 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.
jyoung
Posts: 694
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

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

Post 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
dhnaigles
Posts: 56
Joined: Wed Feb 03, 2016 1:34 am
Location: Marlborough, MA, USA

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

Post 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"?
dannyoorburg
Posts: 177
Joined: Mon Jan 04, 2016 9:50 am
Location: Australia

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

Post 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
dhnaigles
Posts: 56
Joined: Wed Feb 03, 2016 1:34 am
Location: Marlborough, MA, USA

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

Post 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.
Post Reply