Skip to content

Commit 887537a

Browse files
authored
Merge pull request #279868 from xingsy97/socketio-admin
[Azure Web PubSub] Add Socket.IO AdminUI document
2 parents 4096c5b + 82d7e51 commit 887537a

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed
27.8 KB
Loading
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
title: Admin UI
3+
description: This article explains how to use Admin UI when you're using Web PubSub for Socket.IO.
4+
keywords: Socket.IO, Socket.IO on Azure, multi-node Socket.IO, scaling Socket.IO, Socket.IO logging, Socket.IO debugging, socketio, azure socketio
5+
author: xingsy97
6+
ms.author: siyuanxing
7+
ms.date: 07/02/2024
8+
ms.service: azure-web-pubsub
9+
ms.topic: how-to
10+
---
11+
12+
# Azure Socket.IO Admin UI
13+
14+
[Socket.IO Admin UI](https://socket.io/docs/v4/admin-ui/) is a website tool developed by Socket.IO official team and it can be used to have an overview of the state of your Socket.IO deployment. See how it works and explore its advanced usage in [Socket.IO Admin UI Doc](https://socket.io/docs/v4/admin-ui/).
15+
16+
[Azure Socket.IO Admin UI](https://github.com/Azure/azure-webpubsub/tree/main/tools/azure-socketio-admin-ui) is a customized version of it for Azure Socket.IO.
17+
18+
## Deploy the website
19+
Azure Socket.IO Admin UI doesn't have a hosted version so far. Users should host the website by themselves.
20+
21+
The static website files could be either downloaded from release or built from source code:
22+
23+
### Download the released version
24+
1. Download the released zip file such as `azure-socketio-admin-ui-0.1.0.zip` from [release page](https://github.com/Azure/azure-webpubsub/releases)
25+
26+
2. Extract the zip file
27+
28+
### Build from source code
29+
1. Clone the repository
30+
```bash
31+
git clone https://github.com/Azure/azure-webpubsub.git
32+
```
33+
34+
2. Build the project
35+
```bash
36+
cd tools/azure-socketio-admin-ui
37+
yarn install
38+
yarn build
39+
```
40+
41+
3. Host the static files using any HTTP server. Let's use [a tiny static HTTP server](https://www.npmjs.com/package/http-server) as an example:
42+
```bash
43+
cd dist
44+
npm install -g http-server
45+
http-server
46+
```
47+
48+
The http server is hosted on port 8080 by default.
49+
50+
4. Visit `http://localhost:8080` in browser
51+
52+
## Update server-side code
53+
1. install the `@socket.io/admin-ui` package:
54+
55+
```bash
56+
npm i @socket.io/admin-ui
57+
```
58+
59+
2. Invoke the instrument method on your Socket.IO server:
60+
61+
```javascript
62+
const azure = require("@azure/web-pubsub-socket.io");
63+
const { Server } = require("socket.io");
64+
const { instrument } = require("@socket.io/admin-ui");
65+
const httpServer = require('http').createServer(app);
66+
67+
const wpsOptions = {
68+
hub: "eio_hub",
69+
connectionString: process.argv[2] || process.env.WebPubSubConnectionString
70+
};
71+
72+
const io = await new Server(httpServer).useAzureSocketIO(wpsOptions);
73+
instrument(io, { auth: false, mode: "development" });
74+
75+
// Note: The next three lines are necessary to make the development mode work
76+
Namespace.prototype["fetchSockets"] = async function() {
77+
return this.local.fetchSockets();
78+
};
79+
80+
httpServer.listen(3000);
81+
```
82+
83+
## Open Admin UI website
84+
1. Visit `http://localhost:8080` in browser.
85+
86+
2. You should see the following modal:
87+
88+
:::image type="content" source="./media/socketio-troubleshoot-admin-ui/admin-ui-homepage-modal.png" alt-text="Screenshot of modal on Socket.IO Admin UI homepage.":::
89+
90+
3. Fill in your service endpoint and hub name.

articles/azure-web-pubsub/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@
162162
href: socketio-troubleshoot-common-issues.md
163163
- name: Collect logs
164164
href: socketio-troubleshoot-logging.md
165+
- name: Admin UI
166+
href: socketio-troubleshoot-admin-ui.md
165167
- name: Concepts
166168
items:
167169
- name: How does Web PubSub support Socket.IO library

0 commit comments

Comments
 (0)