menu
Channels
Team

Get offline notification

May 24, 2020 at 4:44pm

Get offline notification

May 24, 2020 at 4:44pm
Hi,
Is there a way to get a callback in a Theia extension when Theia goes offline ?
Thanks!

May 24, 2020 at 8:00pm

May 25, 2020 at 5:26am
Thanks!
  • reply
  • like

May 26, 2020 at 4:50pm
It looks like onStatusChange is triggered when a tab browser is not active after a couple seconds. At least on chrome/osx. Select a different tab, select another app, wait 5 seconds and OFFLINE is sent.
Is that the expected behaviour?
  • reply
  • like
I've noticed the same thing when quickly testing. I believe it is because we have a timer (idle) which causes us to fire the status change event:
this.timer = this.setTimeout(() => {
console.log(`No activity for ${this.options.offlineTimeout} ms. We are offline.`);
this.updateStatus(false);
}, this.options.offlineTimeout);
I see the following log:
root INFO No activity for 5000 ms. We are offline.
Perhaps there is an improvement to be made in this area, thank you for reporting the behavior.
  • reply
  • like

May 27, 2020 at 6:04am
Or it means that chromes suspends activities of the background tab and does not send messages over WS anymore or setTimeout behaves differently for such tabs.
  • reply
  • like
Right it looks like setTimeout slows down when in an inactive tab. WebSockets apparently still work as expected.
  • reply
  • like

June 3, 2020 at 3:43pm
Does it make sense to change the pings logic so inactive tab doesn't send those pings at all?
  • reply
  • like

June 4, 2020 at 8:18am
I am not sure, if there is not ping, a user can loose all debugging sessions and so on. So probably no.
  • reply
  • like
what is the expectation for debug sessions, I once opened https://github.com/eclipse-theia/theia/issues/4591 for them being lost on brief disconnections. This means that already today they are lost when chrome tab is not active as according to the above there are disconnects.
  • reply
  • like
I cannot say anything according to the above. There still can be a ping, but the status reported bogusly since timeout behaves differently.
Edited
  • reply
  • like
the debug sessions is only an example, we will have to consider how it affects other services as well.
  • reply
  • like
what about if we need to disconnect sessions after some time of inactivity. do you see this as a contribution or should we rebind FrontendConnectionStatusService in our extension?
  • reply
  • like
I don't know. I will need to debug it to learn more first. I don't like that ping rely on timing of setTimeout, maybe there is a way to rework it first without relying on such timings. But I don't think we need to stop sending ping if the tab is not active.
  • reply
  • like

June 9, 2020 at 1:10pm
We are looking for a way to identify if incoming message is a ping response or not, so we can identify user inactivity. Do you see any issue with adding message content to onIncomingMessageActivity event? Or maybe do you have some other proposal?
  • reply
  • like
AbstractConnectionStatusService.onStatusChange should fire with ONLINE when ping is responded
Edited
  • reply
  • like
Why do you want to know it?
  • reply
  • like
We want stop sending ping messages to backend when user is inactive after some predefined time. In order to detect user inactivity I thought about reading incoming traffic and exclude ping responses somehow. Other direction can be to detect user inactivity by listening to mousemove and keypress events, but then I'm not sure how to listen to webviews events. Maybe do you have other idea?
  • reply
  • like

June 10, 2020 at 8:20am
I wonder what would happen when a user left a terminal to run some important task, but connection times out because there was not any interactions.
Edited
  • reply
  • like
private
This channel has been archived