Rob--W / stackexchange-notifications

Realtime desktop notifications for Stack Exchange sites.
44 stars 8 forks source link

Get notification if socket status stopped? #28

Open orschiro opened 7 years ago

orschiro commented 7 years ago

Dear @Rob--W,

Sometimes the extension simply stops and I don't know why, nor do I get any notification about it.

I then assume that I don't have any new notifications although I do.

For these cases, could the icon display an exclamation mark instead of the number of unread notifications to indicate and tell me that I need to take action?

Yours,

Robert

peek 2017-02-03 08-43-se

Rob--W commented 7 years ago

Can you go to chrome://extensions/, inspect the background page of the extension and show the log? You shouldn't have to manually restart the socket, the extension aims to automatically detect that the socket is down and attempts to re-establish the connection with exponential back-off (capped to at least once per ten minutes).

orschiro commented 7 years ago

Thanks, Rob!

Does this help at all?

image

Rob--W commented 7 years ago

The part of the log that you have shown looks healthy: The connection seems to be closed and re-opened when needed.

Next time you encounter that the notification count is off (and the socket is down), can you look at the bottom of the log of the background console and show it here?

orschiro commented 7 years ago

Yes, I will. Thanks!

orschiro commented 7 years ago

Dear @Rob--W,

It happened again but this time I don't see any error log.

peek 2017-02-06 07-20-se-options

Rob--W commented 7 years ago

That is really odd. At the very least I expect either "Opened WebSocket and subscribed to method [numbers]-topbar" or "Closed WebSocket" or "WebSocket failed".

Could you follow the following steps:

  1. Open the developer tools
  2. Click on the three dots at the upper-right corner, choose Settings (F1).
  3. At the Console heading, tick the "Show timestamps" checkbox.
  4. Refresh the background page, e.g. with F5.
  5. When the issue occurs, click on the Network tab, click on the last line that shows a WebSocket connection to the Stack Exchange WebSocket API, go to the frames tab and take a screenshot of the most recent frames, with the timestamps clearly visible. If you find multiple WebSocket connections in a short timespan at the end, please say so.
  6. Take a screenshot of the JavaScript console.

(instead of a screenshot you can also record a video).

orschiro commented 7 years ago

Thanks for your instructions!

I hope this is what you were looking for:

image

Rob--W commented 7 years ago

I left one important detail in my request, please post the result when you observe that the socket is unexpectedly down. I am expecting heartbeat messages every few minutes; If the socket is somehow closed permanently then the received/sent messages, timestamps and logging messages will help with discovering why the socket unexpectedly closes.

orschiro commented 7 years ago

I see. So at best, I should send you the screenshot immediately after it shut down, correct?

Well, that's very hard. I can never be sure when it closes the connection. I usually don't get new messages for days, So sometimes, I don't even check it for a long time and don't expect anything to appear.

Rob--W commented 7 years ago

I see. So at best, I should send you the screenshot immediately after it shut down, correct?

Any time after shutdown is OK, because once stuck in the shutdown state, there isn't going to be any other network activity. At the very least I want to see the console messages; the network tab is a nice-to-have.

orschiro commented 7 years ago

OK!

I will provide you with that.

Actually, thinking about it, what would help debugging:

Can the icon show "0" if there are no new messages? And as soon as the socket stops it would show nothing anymore, correct?

Not even 0.

On Tue, Feb 7, 2017 at 11:36 AM Rob Wu notifications@github.com wrote:

I see. So at best, I should send you the screenshot immediately after it shut down, correct?

Any time after shutdown is OK, because once stuck in the shutdown state, there isn't going to be any other network activity. At the very least I want to see the console messages; the network tab is a nice-to-have.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Rob--W/stackexchange-notifications/issues/28#issuecomment-277960988, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKbw5THoHKnIzEMB9j6jFo-mkKeB4-gks5raEk0gaJpZM4L2CyM .

Rob--W commented 7 years ago

When the socket is down, the message count is whatever the last count was. This can be 0, but also 1 or 10. The socket going down is handled gracefully, the extension reconnects and upon success fetches the socket count via the StackExchange API if you have authenticated with oAuth at the options page.

If you want to be notified of socket events, run the following snippet in the background script's console,

eventEmitter.on('socket', function(status) {
    console.log('Socket status = ' + status);
    setTimeout(function() {
        alert('Socket status ' + status);
    }); // Non-blocking.
});
orschiro commented 7 years ago

OK, done!

And now I just have to wait?

image