netcreateorg / netcreate-2018

Please report bugs, problems, ideas in the project Issues page: https://github.com/netcreateorg/netcreate-2018/issues
Other
11 stars 2 forks source link

Feature: Heartbeat #107

Closed benloh closed 4 years ago

benloh commented 4 years ago

There are two ways that an end user's browser might get disconnected from the server:

  1. NetCreate Server Disconnects
  2. User loses internet connection

This pull request implements the latter.

1. NetCreate Server Disconnects

UNISYS will detect when the server is disconnecting and send a disconnect message to all clients. The browser will detect that message and show a "Server Disconnect" message. See e134f82977493f1e0af425f5a4c133525cdf837f

2. Lose Internet Connection

If the user loses the internet connect, e.g. wifi drops out, ethernet cable is disconnected, the javascript WebSocket client will not detect the loss of connection.

In order to detect a loss of connection, we have to implement a heartbeat. Here's how that works:

  1. SERVER: When a client makes a new websocket connection to the server, the server sets an interval timer that will periodically send a "heartbeat" message to the client websocket.
  2. CLIENT: When a client initiates a new websocket connection to the server, the client will start a countdown timer that waits for a "heartbeat" message from the server.
  3. SERVER: Every 5 seconds, the server will send a "heartbeat" to any saved client websockets.
  4. CLIENT: When the client receives a "heartbeat" message, it resets the countdown timer.
  5. CLIENT: If the client doesn't receive a "heartbeat" message before the countdown timer runs out, the connection is marked disconnected and a "Server Disconnected" message is displayed.

Setting the Heartbeat Interval

You can set the heartbeat interval in build/app/unisys/common-defs.js. Set it:

It is currently set to 5 seconds.

The time is set in milliseconds.

To Test

  1. Check out the repo and start the server.
    git checkout dev-bl/config-ip-heartbeat
    npm run dev
  2. On the client machine, point your browser at the server.
  3. On the client machine, turn off wifi or disconnect any network cables to disable the network.
  4. In about 5 or 6 seconds, the browser should display "Server Disconnected".

Reconnect your network connection and test the server going down.

  1. On the client machine, point your browser at the server.
  2. On the server, hit ctrl-c to stop the server.
  3. The client machine should immediately display "Server Disconnected".

Notes

benloh commented 4 years ago

@jdanish please test the heartbeat implementation.

kalanicraig commented 4 years ago

I had several students who didn’t have internet at home, and we used the fact that the client-side load keeps the network viz and data intact (with no editing, obviously) to give those students more-or-less on-demand view access, even if they didn’t have editing privileges.

Can we set a red bar across the top that says “PLEASE DON’T ADD OR REVISE NETWORK DATA IN OFFLINE MODE. You seem to be offline. Any edits you make will not be saved. Reload to see new edits when your internet connection is restored” rather than having an overlay that stops folks from playing with the graph and looking at data? (That don’t edit text might be too long; cut as needed.)

I also instructed those students to make sure they didn’t put in an access token when the loaded the network, so we can tackle the issue of multiple versions of the DB with both human engineering and the big red “Don’t edit” bar.

Thanks, Kalani

On Aug 8, 2020, at 6:24 PM, benloh notifications@github.com wrote:

@jdanish https://github.com/jdanish please test the heartbeat implementation.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/netcreateorg/netcreate-2018/pull/107#issuecomment-670980086, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACKL4NCDQGS2PLSAOQPZ37DR7XGCNANCNFSM4PY3S4PA.

jdanish commented 4 years ago

This is a requested change to the modal lock down message, which seems to work great by the way.


(from my iPhone)

Joshua Danish http://www.joshuadanish.com

On Aug 9, 2020, at 5:27 PM, Kalani Craig notifications@github.com wrote:

 I had several students who didn’t have internet at home, and we used the fact that the client-side load keeps the network viz and data intact (with no editing, obviously) to give those students more-or-less on-demand view access, even if they didn’t have editing privileges.

Can we set a red bar across the top that says “PLEASE DON’T ADD OR REVISE NETWORK DATA IN OFFLINE MODE. You seem to be offline. Any edits you make will not be saved. Reload to see new edits when your internet connection is restored” rather than having an overlay that stops folks from playing with the graph and looking at data? (That don’t edit text might be too long; cut as needed.)

I also instructed those students to make sure they didn’t put in an access token when the loaded the network, so we can tackle the issue of multiple versions of the DB with both human engineering and the big red “Don’t edit” bar.

Thanks, Kalani

On Aug 8, 2020, at 6:24 PM, benloh notifications@github.com wrote:

@jdanish https://github.com/jdanish please test the heartbeat implementation.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/netcreateorg/netcreate-2018/pull/107#issuecomment-670980086, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACKL4NCDQGS2PLSAOQPZ37DR7XGCNANCNFSM4PY3S4PA.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

benloh commented 4 years ago

Non-modal server disconnect message implemented with 8648e3d10e6f6f0600c46c06221a4ad58a4c1776