Is this TWs server accessible?

[I’ve edited this OP. It was initially ambiguous if I asked for a way to see if the user had a general internet connection or if the wiki had server connection]

In another thread I wondered if it is possible to tell if the wiki has access to its server.

…and, if so, could the InfoMechanism be enhanced to provide this info?

It seems reasonable that it should work; it is simple enough to try to load e.g an iframe to see if it times out. Maybe something similar could ping the server and convert the result into a state?

I assume you mean not whether it was loaded via http vs local — since that’s fairly straightforward (and doesn’t require a ping).

But if it’s not that, then it seems you want to know, in real time, whether the server is available and connected. So the question is: how often would you want this to update? And, with a service like TiddlyHost (especially given its backup history archive service), why would this be any better than having auto-save, with a clear notification of failure to save (presumably because of lack of connection to server)?

(I do think that a clearer notification of failure to save — or better persistence of the “Saving…” notification until/unless “Saved” is confirmed — is a good request!)

Is your worry more about the possibility of TiddlyHost (or some othe specific server) being down (or no longer having your login credentials active), or is it more about whether a laptop (say) is currently connected to the internet during a commute — which could obviously change at any moment?

Either way, having a frequent empty handshake with the server seems like a costly (computing/bandwidth) way to have only a 99.x% guarantee that your next save will work (given that internet connection can still be lost between the time of your last ping and the time you attempt to save to server).

Of course, I’d be happy to be persuaded otherwise. Maybe a once per minute check would not be too costly, and could yield a visually clear shift that helps remind me that I need to be mindful of the need to make local saves… (For similar reasons, I have a page-background-color difference between “reader” and “author” mode for public projects hosted on TiddlyWiki. Since I often check in another browser account to ensure things are displaying as they should for student visitors, it’s helpful for that load-instance to have a different background color. It doesn’t mean the server’s not “online” — but it does help inhibit me from jumping in to make a quick edit, since I’m not authenticated for this session.)

@Springer , all valid questions.

I do not mean whether it was loaded via http or local, but rather what the state of the device is now.

But I’m mostly thinking of the use case that if saving to the could fails due to offline, then TW could automatically download instead.

But, sure, in addition to that then, sure, a constant pinging for a little indicator icon somewhere assuming it could work in the background and not freeze up the TW. I’d be happy with a minutely check but even if it would take place much more frequently, it can’t be more costly than watching youtube videos, or doing other things online that transfers a lot of data, can it?

1 Like

You can use the new tm-http-request message and load a tiny file from your URL.

Or you can use the method=OPTIONS, then check the status. If it’s a 2xx you got something back. So it’s very likely that it is a server.

If you request OPTIONS from tiddlywiki.com you’ll get a 405 which is : 405 Method Not Allowed - HTTP | MDN – Which still means it’s online, because the server responded with 405

You can also try to load a small static file from tw-com eg: https://tiddlywiki.com/static/favicon.ico and check the file content or the header:status info

2 Likes

@pmario , thanks, that sounds like quite a few options - even if I don’t directly understand how to practically implement any of them (but I’m sure I could figure it out). Would it make sense for me to post a gh request for the info mechanism to somehow feature this, so users have an easily accessible tool for this?

Thirty seconds after I shut down a Node server, a wiki served from it gets this message:

and every five to ten seconds afterward it updates the count in the top line. Less than five seconds after I restart it, that message disappears.

I don’t know how this might apply to other savers.

That’s a coincidence. If you would have waited 6 more seconds, it would have been 59 seconds :wink: TW checks for new tiddlers every minute. So “worst case” this info goes away after 1 minute if server connection comes back.

Interesting, as I tried three separate times and each was under 5 seconds. I assumed it was something short, like perhaps 10 seconds. So that would be quite the coincidence…, but, … are you certain there’s not a faster cadence once the disconnection is noticed? Because that count in the top is incrementing a lot faster than once per minute. I haven’t gone to look into the code, because I still wouldn’t really know where to look.

The update could be faster, if you do interact with the wiki and it wants to connect to the server. But if you leave the tab alone, it should be 1 minute. See: TiddlyWiki5/core/modules/syncer.js at 91e0b2afb6e6729d9f5f8333a88db83d77133489 · Jermolene/TiddlyWiki5 · GitHub

see: .pollTimerInterval

I do not understand why the info/url/protocol is not good enough?

The problem is, that it depends on the server that is used. So it’s hard to get a generic solution. IMO it will always be very user specific.

Ok, thanks. That makes sense.

But, really. who leaves their wiki alone for a whole minute? :wink:

Hm, does that at all tell if the user has “current” access to the server of the seen wiki?

The browser provides window.navigator.onLine which could be read via a js macro. if you want to know if you have network connectivity… but the website could be down all the same.

1 Like

Thanks @buggyj but there’s typically a device screen indicator for general internet connection so I guess that’s enough but what is needed is wiki-source connection. (However I’m noticing now that the OP is not clear what I ask for so I’ll correct it!)