-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.md
53 lines (31 loc) · 1.75 KB
/
README.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Websocket Broadcasting with Go-Fiber and RabbitMQ
![websocket.gif](./docs/websocket.gif)
This project demonstrates a WebSocket broadcasting application with multi-processing capabilities using Fiber and RabbitMQ as the message broker. It allows multiple processes to handle WebSocket connections and efficiently broadcast messages to connected clients.
Please note that the project uses the following technologies:
- [Go-Fiber](https://github.com/gofiber/fiber): A fast and efficient web framework for Go.
- [RabbitMQ](https://www.rabbitmq.com/): A powerful and flexible open-source message broker.
## Prerequisites
Before running the application, ensure you have the following installed:
- Go (1.16 or higher): https://golang.org/dl/
- RabbitMQ Server: https://www.rabbitmq.com/download.html
## Installation
1. Clone this repository to your local machine:
```
git clone https://github.com/onionj/websocket-broadcasting.git
cd websocket-broadcasting
```
2. Fetch the required dependencies using Go Modules:
```
go mod download
```
## Configuration
Ensure you have RabbitMQ running on your local machine or update the configuration settings in `config.json` to match your RabbitMQ server.
## Usage
To run the WebSocket broadcasting application, use the following command:
```
go run main.go
```
The application will start, and you can visit `http://localhost:8080` in your browser to interact with the WebSocket server.
## How it Works
The application uses Fiber to handle incoming WebSocket connections and messages. When a WebSocket connects, the server add it to a list.
Each process has a queue bound to a FANOUT exchange. When a message is pushed to the exchange, all queues receive the message, and each process sends the message to the connected websockets.