Skip to content

Commit b08a478

Browse files
committed
Update server-client-communication.adoc
- Fix heading levels - Other minor edits
1 parent 2166556 commit b08a478

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

articles/flow/advanced/server-client-communication.adoc

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ order: 800
77

88
= Sync Server & Client UI States
99

10-
Server to client communications contain the synchronization tokens -- `syncId` (server-to-client) and `clientId` (client-to-server) -- for communicating and UI state tracking. This tracking is meant for ordering messages. It's also used to verify that both sides are in the same known state.
10+
Server to client communications contain the synchronization tokens for communicating and UI state tracking. This tracking is meant for ordering messages. It's also used to verify that both sides are in the same known state.
11+
12+
== Synchronization Tokens
1113

1214
The `syncId` token marks the state of the server and is returned as received by the client. Whereas, the `clientId` token is incremented for each message sent by the client, with the server incrementing to match the next id in the response. Both `syncId` and `clientId` are integers.
1315

1416

15-
==== `syncId`
17+
=== syncId
1618

1719
The `syncId` holds the latest communication state identifier given by the server. It's generated as a strictly increasing id for each response to every request from the client.
1820

@@ -23,7 +25,7 @@ The initial value when no response has been received from the server is `UNDEFIN
2325
The `syncId` is always incremented by 1 after a new UIDL response is generated. The client then handles the received messages according to the `syncId` and the latest handled `syncId`, so that changes are handled in the correct order.
2426

2527

26-
==== `clientId`
28+
=== clientId
2729

2830
The `clientId` holds the latest communication state identifier given by the client. The client token is incremented on the client after sending the message. The server increments the value in the response to match the next expected `clientId` (i.e., client updated after message sent).
2931

@@ -32,39 +34,39 @@ On the client, pending messages are removed from the queue as handled when `clie
3234
On the server, in cases where the id is the previous one with the same request payload, the server re-sends the latest response since the client probably didn't receive the message. If the client-sent id doesn't match the server-expected id, a re-synchronization is initiated.
3335

3436

35-
= UI State Re-Synchronization
37+
== UI State Re-Synchronization
3638

3739
Re-synchronization occurs when the client detects that its state is no longer in sync with the server. This can happen due to unexpected network interruptions, or inconsistencies between the client-side UI and server-side state caused by misconfigured reverse proxies or session replication setups.
3840

3941
Several factors can lead to message loss or unexpected message identifiers:
4042

41-
- *Incorrect load balancer or reverse proxy configuration:* Using setups without sticky sessions may result in receiving messages from the server which were meant for a different session or UI.
42-
- *Firewall or Virtual Private Network (VPN) interference:* Deep packet inspection can block certain packets.
43+
- *Incorrect load balancer or reverse proxy configuration*: Using setups without sticky sessions may result in receiving messages from the server which were meant for a different session or UI.
44+
- *Firewall or Virtual Private Network (VPN) interference*: Deep packet inspection can block certain packets.
4345

4446
These factors might also generate a delay in arrival of the messages. Virus scanners are particularly problematic and may cause issues when `WebSocket_XHR` is used. Increasing the `maxMessageSuspendTimeout` parameter value could help mitigate message arrival delays.
4547

4648
Other potential causes include:
4749

48-
- *Faulty router hardware:* This could be due to routers using outdated firmware versions.
50+
- *Faulty router hardware*: This could be due to routers using outdated firmware versions.
4951
- *Unstable Wi-Fi or cellular connections*: Fluctuating network conditions can disrupt communication.
50-
- *Server-side issues:* Request-handling hiccups may lead to inconsistencies, possibly due to server performance degradation.
52+
- *Server-side issues*: Request-handling hiccups may lead to inconsistencies, possibly due to server performance degradation.
5153

5254

53-
== Re-Synchronization Initiation & Mechanism
55+
=== Re-Synchronization Initiation & Mechanism
5456

5557
Re-synchronization is initiated by the client when it can't find a message with the expected `syncId` among the pending messages from the server within a given timeout. The default is 5 seconds, which is configurable using the `maxMessageSuspendTimeout` parameter. Below is the process followed to re-synchronize:
5658

57-
*Client Initiation:*
59+
*Client Initiation*:
5860

5961
- The client clears the queue of pending messages from the server.
6062
- It terminates the current request and sends a re-synchronization request to the server.
6163

62-
*Server Handling:*
64+
*Server Handling*:
6365

6466
- Upon receiving the re-synchronization request, the server invokes the detached listeners of UI components and re-attaches all components to the state tree.
6567
- The server then sends a response that includes the current UI state needed to rebuild the client-side state tree.
6668

67-
*Client Update:*
69+
*Client Update*:
6870

6971
- The client receives the updated UI state from the server.
7072
- It clears all old pending messages, updates the last known `syncId` to the newly received value, and rebuilds the DOM tree from scratch based on the server's current state.

0 commit comments

Comments
 (0)