Multi-process Websocket broadcasting with Fiber and RabbitMQ
MIT License
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:
Before running the application, ensure you have the following installed:
git clone https://github.com/onionj/websocket-broadcasting.git
cd websocket-broadcasting
go mod download
Ensure you have RabbitMQ running on your local machine or update the configuration settings in config.json
to match your RabbitMQ server.
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.
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.