I have created a “control panel” UI in KLWP that displays/controls a server on a remote machine that has an open http port on 5001. That server may not be running at a given time (indeed one thing the control panel does is permit stop/start of the server) and I need to know, in a timely fashion, if the server is reachable/running.
My first approach was to use $wg(“http://IP:port”, raw)$ in a formula for a global variable. But I see two problems with this:
(a) I don’t know what the standard interval is for KLWP to refesh the variable and it may not be frequent enough. I have read about and tried putting the wg() inside a tu(seq) in an effort to force more frequent updates. But it doesn’t appear I am doing that right or it doesn’t work.
(b) the $wg()$ function seems to use a cache and so if the server is not reachable, it appears to return something anyhow and that defeats my purpose.
So I considered using a flow as I understand the wget action in flows do NOT use a cache. I can do this and it would be fine. I could run it on a cron. But it seems like the best I can do with the flow cron mechanism is to trigger once every 2 minutes. using “*/2 * * * *”. That is fine for many things but not frequent enough for this. I am no cron expert so maybe I can do better somehow?
So now I am considering other possibilities:
I realize that part of this is easily done using nc() stuff. Clearly, if there is no connection, there is no way to reach the server. But my phone could have connectivity in general but still not be able to reach the server IP. I can shell out to ping to test that, I guess.
The hard part for me is to test if the port is available. As my phone is rooted and has busybox installed, I can telnet to the IP/Port and find out that way. But that will not work on my wife’s phone, for example, which is NOT rooted.
So I am trolling for another approach and appreciate your help/ideas. Thanks