You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-web-pubsub/concept-service-internals.md
+15-13Lines changed: 15 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ author: vicancy
5
5
ms.author: lianwei
6
6
ms.service: azure-web-pubsub
7
7
ms.topic: conceptual
8
-
ms.date: 09/30/2022
8
+
ms.date: 08/09/2024
9
9
---
10
10
11
11
# Azure Web PubSub service internals
@@ -14,7 +14,7 @@ Azure Web PubSub Service provides an easy way to publish/subscribe messages usin
14
14
15
15
- Clients can be written in any language that has Websocket support.
16
16
- Both text and binary messages are supported within one connection.
17
-
-There's a simple protocol for clients to do direct client-to-client message publishing.
17
+
-A simple protocol allows you to publish massages directly to each other.
18
18
- The service manages the WebSocket connections for you.
19
19
20
20
## Terms
@@ -35,7 +35,7 @@ Workflow as shown in the above graph:
35
35
36
36
## Client protocol
37
37
38
-
A client connection connects to the `/client` endpoint of the service using [WebSocket protocol](https://tools.ietf.org/html/rfc6455). The WebSocket protocol provides full-duplex communication channels over a single TCP connection and was standardized by the IETF as RFC 6455 in 2011. Most languages have native support to start WebSocket connections.
38
+
A client connection connects to the `/client` endpoint of the service using [WebSocket protocol](https://tools.ietf.org/html/rfc6455). The WebSocket protocol provides full-duplex communication channels over a single TCP connection and follows all the standards of the IETF as RFC 6455 in 2011. Most languages have native support to start WebSocket connections.
39
39
40
40
Our service supports two kinds of clients:
41
41
@@ -59,12 +59,12 @@ var client2 = new WebSocket(
59
59
);
60
60
```
61
61
62
-
A simple WebSocket client follows a client<->server architecture, as the below sequence diagram shows:
62
+
A simple WebSocket client follows a client<->server architecture, as the following sequence diagram shows:
63
63

64
64
65
65
1. When the client starts a WebSocket handshake, the service tries to invoke the `connect` event handler for WebSocket handshake. Developers can use this handler to handle the WebSocket handshake, determine the subprotocol to use, authenticate the client, and join the client to groups.
66
66
2. When the client is successfully connected, the service invokes a `connected` event handler. It works as a notification and doesn't block the client from sending messages. Developers can use this handler to do data storage and can respond with messages to the client. The service also pushes a `connected` event to all concerning event listeners, if any.
67
-
3. When the client sends messages, the service triggers a `message` event to the event handler to handle the messages sent. This event is a general event containing the messages sent in a WebSocket frame. Your code needs to dispatch the messages inside this event handler. If the event handler returns non-successful response code for, the service drops the client connection. The service also pushes a `message` event to all concerning event listeners, if any. If the service can't find any registered servers to receive the messages, the service also drops the connection.
67
+
3. When the client sends messages, the service triggers a `message` event to the event handler to handle the messages sent. This event is a general event containing the messages sent in a WebSocket frame. Your code needs to dispatch the messages inside this event handler. If the event handler returns nonsuccessful response code for, the service drops the client connection. The service also pushes a `message` event to all concerning event listeners, if any. If the service can't find any registered servers to receive the messages, the service also drops the connection.
68
68
4. When the client disconnects, the service tries to trigger the `disconnected` event to the event handler once it detects the disconnect. The service also pushes a `disconnected` event to all concerning event listeners, if any.
69
69
70
70
#### Scenarios
@@ -127,7 +127,7 @@ A PubSub WebSocket client can:
127
127
128
128
[PubSub WebSocket Subprotocol](./reference-json-webpubsub-subprotocol.md) contains the details of the `json.webpubsub.azure.v1` subprotocol.
129
129
130
-
You may have noticed that for a [simple WebSocket client](#the-simple-websocket-client), the _server_ is a **must have** role to receive the `message` events from clients. A simple WebSocket connection always triggers a `message` event when it sends messages, and always relies on the server-side to process messages and do other operations. With the help of the `json.webpubsub.azure.v1` subprotocol, an authorized client can join a group and publish messages to a group directly. It can also route messages to different event handlers / event listeners by customizing the _event_ the message belongs.
130
+
You noticed that for a [simple WebSocket client](#the-simple-websocket-client), the _server_ is a **must have** role to receive the `message` events from clients. A simple WebSocket connection always triggers a `message` event when it sends messages, and always relies on the server-side to process messages and do other operations. With the help of the `json.webpubsub.azure.v1` subprotocol, an authorized client can join a group and publish messages to a group directly. It can also route messages to different event handlers / event listeners by customizing the _event_ the message belongs.
131
131
132
132
#### Scenarios
133
133
@@ -184,7 +184,7 @@ Client events fall into two categories:
184
184
- `connect`: This event is for event handler only. When the client starts a WebSocket handshake, the event is triggered and developers can use `connect` event handler to handle the WebSocket handshake, determine the subprotocol to use, authenticate the client, and join the client to groups.
185
185
- `message`: This event is triggered when a client sends a message.
186
186
- Asynchronous events (non-blocking)
187
-
Asynchronous events don't block the client workflow, it acts as some notification to server. When such an event trigger fails, the service logs the error detail.
187
+
Asynchronous events don't block the client workflow. Instead, they act as some notification to the server. When such an event trigger fails, the service logs the error detail.
188
188
- `connected`: This event is triggered when a client connects to the service successfully.
189
189
- `disconnected`: This event is triggered when a client disconnected with the service.
190
190
@@ -202,7 +202,7 @@ The following graph describes the workflow.
202
202
203
203

204
204
205
-
As you may have noticed when we describe the PubSub WebSocket clients, that a client can publish to other clients only when it's _authorized_ to. The `role`s of the client determines the _initial_ permissions the client have:
205
+
As you noticed when we describe the PubSub WebSocket clients, that a client can publish to other clients only when it's _authorized_ to. The `role`s of the client determines the _initial_ permissions the client have:
@@ -250,11 +250,13 @@ For now, we don't support [WebHook-Request-Rate](https://github.com/cloudevents/
250
250
251
251
#### Authentication/Authorization between service and webhook
252
252
253
+
To Establish secure authentication and authorization between your service and webhook, consider the following options and steps:
254
+
253
255
- Anonymous mode
254
256
- Simple authentication that `code` is provided through the configured Webhook URL.
255
257
- Use Microsoft Entra authorization. For more information, see [how to use managed identity](howto-use-managed-identity.md) for details.
256
-
- Step1: Enable Identity for the Web PubSub service
257
-
- Step2: Select from existing Microsoft Entra application that stands for your webhook web app
258
+
- Step 1: Enable Identity for the Web PubSub service
259
+
- Step 2: Select from existing Microsoft Entra application that stands for your webhook web app
258
260
259
261
### Connection manager
260
262
@@ -292,17 +294,17 @@ Currently we support [**Event Hubs**](https://azure.microsoft.com/products/event
292
294
293
295
You need to register event listeners beforehand, so that when a client event is triggered, the service can push the event to the corresponding event listeners. See [this doc](./howto-develop-event-listener.md#configure-an-event-listener) for how to configure an event listener with an event hub endpoint.
294
296
295
-
You can configure multiple event listeners. The order of the event listeners doesn't matter. If an event matches with multiple eventlisteners, it will be sent to all the listeners it matches. See the following diagram for an example. Let's say you configure four event listeners at the same time. Then a client event that matches with three of those listeners will be sent to three listeners, leaving the rest one untouched.
297
+
You can configure multiple event listeners, and their order doesn't affect their functionality. If an event matches multiply listeners, the event is dispatched to all matchinglisteners. See the following diagram for an example. For example, ifyou configure four event listeners simultaneously, each listener receiving a match processes the event. Aclient event that matches with three of those listeners is sent to three listeners, leaving the rest one untouched.
296
298
297
299
:::image type="content" source="media/concept-service-internals/event-listener-data-flow.svg" alt-text="Event listener data flow diagram sample":::
298
300
299
-
You can combine an [event handler](#event-handler) and event listeners for the same event. In this case, both event handler and event listeners will receive the event.
301
+
You can combine an [event handler](#event-handler) and event listeners for the same event. Inthis case, both event handler and event listeners receive the event.
300
302
301
303
Web PubSub service delivers client events to event listeners using [CloudEvents AMQP extension for Azure Web PubSub](reference-cloud-events-amqp.md).
302
304
303
305
### Summary
304
306
305
-
You may have noticed that the _event handler role_ handles communication from the service to the server while _the manager role_ handles communication from the server to the service. After combining the two roles, the data flow between service and server looks similar to the following diagram using HTTP protocol.
307
+
You noticed that the _event handler role_ handles communication from the service to the server while _the manager role_ handles communication from the server to the service. Once you combine the two roles, the data flow between service and server looks similar to the following diagram using HTTP protocol.
306
308
307
309

0 commit comments