Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Jason WebSocket reconnection (#47) #75

Merged
merged 124 commits into from
Jan 16, 2020
Merged

Jason WebSocket reconnection (#47) #75

merged 124 commits into from
Jan 16, 2020

Conversation

evdokimovs
Copy link
Contributor

@evdokimovs evdokimovs commented Dec 12, 2019

Part of #47

Required for #51

Synopsis

Currently, when connection between server and client is lost, nothing happen. But we need mechanism of reconnection with some deadline and delay between reconnection tries.

Note that in this PR will be implemented only WebSocket reconnection without state synchronization. Synchronization of the Jason state will be implemented in #51.

Solution

  • 1. Send Event::RpcSettingsUpdated with idle_timeout and reconnection_timeout from a server
  • 2. Implement reconnection in RpcTransport
  • 3. Implement reconnection in RpcClient
  • 4. Add delay for RpcClient reconnection tries
  • 5. Add deadline for RpcClient reconnection (which will be calculated based on Event::RpcSettingsUpdated)
  • 6. Add tests for this functional

Checklist

  • Created PR:
    • In draft mode
    • Name contains WIP: prefix
    • Name contains issue reference
    • Has k:: labels applied
    • Has assignee
  • Documentation is updated (if required)
  • Tests are updated (if required)
  • Changes conform code style
  • CHANGELOG entry is added (if required)
  • FCM (final commit message) is posted
    • and approved
  • Review is completed and changes are approved
  • Before merge:
    • Milestone is set
    • PR's name and description are correct and up-to-date
    • WIP: prefix is removed
    • All temporary labels are removed

@evdokimovs evdokimovs added feature New feature or request k::api Related to API (application interface) labels Dec 12, 2019
@evdokimovs evdokimovs added this to the 0.2.0 milestone Dec 12, 2019
@evdokimovs evdokimovs self-assigned this Dec 12, 2019
@evdokimovs
Copy link
Contributor Author

evdokimovs commented Dec 12, 2019

FCM

Jason WebSocket reconnection (#75, #47)

- implement `RpcClient`reconnection
- add 'ServerMsg::RpcSettings' and this message sending and processing
- add 'Room.on_connection_loss' callback which fires when 'RpcClient' loses connection
- add 'ReconnectorHandle' which is used on JS side for reconnection starting (or not)
- implement reconnection with backoff and simple reconnection with delay
- add connection loss notification with button for manual reconnection to the 'e2e-demo'
- add WebSocket connection state indicator to the 'demo'
- remove 'RpcTransport::on_close` and use `RpcTransport::on_state_change` instead of it

Additionally:
- rewrite 'satisfies_by_device_id' macro and 'console_error' macro as functions
- remove 'weak_map!' macro and add 'upgrade_or_detached!' instead of it
- add 'new_js_error!' macro for creating 'JasonError' with 'tracerr' information for JS side
- reverse `ping-pong` mechanism: server sends 'Ping' and expects 'Pongs' from clients now
- add 'rpc.ping_interval' configuration
- use 'fakerator' instead of 'faker' for generating random male usernames in demos

@evdokimovs
Copy link
Contributor Author

evdokimovs commented Jan 2, 2020

FCM

Jason WebSocket reconnection (#75, #47)

- impl RpcClient reconnection
- add ServerMsg::RpcSettings and its sending/processing
- add Room.on_connection_loss callback which fires when RpcClient loses connection
- add ReconnectHandle for JS side to start reconnection
- impl reconnection with backoff and simple reconnection with a constant retry delay
- add connection loss notification with button for manual reconnection to 'e2e-demo' app
- add WebSocket connection state indicator to 'demo' app
- remove RpcTransport::on_close and use RpcTransport::on_state_change instead

Additionally:
- rewrite 'satisfies_by_device_id!' and 'console_error!' macros as functions
- remove 'weak_map!' macro and add 'upgrade_or_detached!' instead
- add 'new_js_error!' macro for creating JasonError with 'tracerr' information for JS side
- reverse ping/pong mechanism: server sends Ping and expects Pong from client
- add 'rpc.ping_interval' configuration option for Medea
- use 'fakerator' instead of 'faker' for generating random male usernames in demos

@evdokimovs evdokimovs requested a review from alexlapa January 2, 2020 22:38
Copy link
Collaborator

@alexlapa alexlapa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evdokimovs ,
LGTM.
Retest, update FCM. If everything is ok, then send to tyranron.

@evdokimovs evdokimovs requested a review from tyranron January 8, 2020 11:04
proto/client-api/src/lib.rs Outdated Show resolved Hide resolved
src/signalling/participants.rs Outdated Show resolved Hide resolved
src/api/client/session.rs Outdated Show resolved Hide resolved
jason/demo/index.html Outdated Show resolved Hide resolved
jason/src/utils/mod.rs Outdated Show resolved Hide resolved
jason/src/rpc/websocket.rs Outdated Show resolved Hide resolved
jason/src/rpc/websocket.rs Outdated Show resolved Hide resolved
jason/src/rpc/heartbeat.rs Outdated Show resolved Hide resolved
jason/src/rpc/reconnect_handle.rs Outdated Show resolved Hide resolved
@evdokimovs evdokimovs changed the title WIP: Jason WebSocket reconnection (#47) Jason WebSocket reconnection (#47) Jan 16, 2020
@evdokimovs evdokimovs merged commit 73673fb into master Jan 16, 2020
@evdokimovs evdokimovs deleted the 47-rpc-reconnection branch January 16, 2020 12:49
@tyranron tyranron added enhancement Improvement of existing features or bugfix k::design Related to overall design and/or architecture k::refactor Refactoring, technical debt elimination and other improvements of existing code base labels Jan 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Improvement of existing features or bugfix feature New feature or request k::api Related to API (application interface) k::design Related to overall design and/or architecture k::refactor Refactoring, technical debt elimination and other improvements of existing code base
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants