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
# AlpacaWebsocketProxy: Share a Single WebSocket Connection for Multiple Clients (C++)
2
-
AlpacaWebSocketProxy provides a C++ WebSocket proxy framework that empowers you to share a single WebSocket connection among multiple clients, maximizing resource utilization and streamlining real-time data access.
3
-
4
-
## Built for Efficiency: Serving Multiple Clients with One Connection
5
-
Designed initially for the [Alpaca.Market](https://alpaca.markets/), which offers data via both REST and WebSockets. However, Alpaca limits the number of concurrent WebSocket connections per account. AlpacaWebSocketProxy solves this by enabling multiple strategies under the same account to receive real-tine market data updates through a single, shared WebSocket connection.
6
-
7
-
## Components and Communication
8
-
AlpacaWebSocketProxy consists of two components:
9
-
1. Standalone proxy server executable: This executable acts as the central communication hub. It manages the connection to the WebSocket server and handles data forwarding between clients. It's launched upon the first client attempting a WebSocket connection, ensuring only one server instance runs simultaneously. Any subsequent server launch attempts automatically terminate, preventing resource conflicts. The server continues execution until all connected clients are closed.
10
-
2. Header-only Proxy Client: This lightweight client library integrates into your individual applications. It manages communication with the proxy server and provides a familiar interface for sending and receiving data.
11
-
12
-
## Benefits of AlpacaWebSocketProxy
13
-
* Efficient Resource Utilization: Share a single WebSocket connection, reducing overhead and improving resource management.
14
-
* Real-Time Data Streamlining: Multiple trading strategies within an account gain access to crucial market updates concurrently.
15
-
* Simplified Integration: The header-only client library enables effortless integration with your existing client applications.
16
-
* Shared Memory Optimization: Communication between server and clients leverages shared memory ring buffers, ensuring high-performance data exchange.
1
+
# WebsocketProxy: Share a Single WebSocket Connection for Multiple Clients (C++)
2
+
WebsocketProxy is a C++ framework that allows multiple clients to share a single WebSocket connection, optimizing resource usage and enhancing real-time data access.
3
+
4
+
## Efficiently Serve Multiple Clients
5
+
Originally designed for [Alpaca.Market](https://alpaca.markets/), which provides data through both REST and WebSockets. However, Alpaca only allows one WebSocket connection per account. WebsocketProxy enables multiple strategies under the same account to receive real-time market data updates via a single shared WebSocket connection. WebsocketProxy doesn't have any Alpaca API protocol. It passes through messages between clients and server, making it suitable for other WebSocket connections as well.
6
+
7
+
## Components
8
+
WebsocketProxy comprises two main components:
9
+
1.**Standalone Proxy Server**: This executable serves as the central communication hub, managing the WebSocket server connection and data forwarding between clients. It launches with the first client connection attempt, ensuring only one server instance runs at a time. Subsequent server launch attempts are automatically terminated to prevent conflicts. The server continues running until all clients disconnect.
10
+
2.**Header-only Proxy Client**: This lightweight client library integrates seamlessly into your applications, managing communication with the proxy server and providing an interface for data transmission.
11
+
12
+
## Installation
13
+
14
+
To install WebsocketProxy, simply download the latest release from the [releases page](https://github.com/kzhdev/websocket_proxy/releases), unzip the package, and copy the `include` folder to your project directory.
15
+
16
+
Then, derive from the `WebsocketProxyCallback` class and implement the corresponding callback functions. For reference, check the Alpaca WebSocket client example in the [example](https://github.com/kzhdev/websocket_proxy/tree/main/example) directory.
17
+
18
+
19
+
## Build From the Source Code
20
+
21
+
To build WebsocketProxy, follow these steps:
22
+
23
+
### Installing Dependencies
24
+
25
+
WebsocketProxy relies on several external libraries. You can install these dependencies using [vcpkg](https://github.com/microsoft/vcpkg). Follow these steps to install the required libraries:
26
+
27
+
1.**Install vcpkg**:
28
+
```sh
29
+
git clone https://github.com/microsoft/vcpkg.git
30
+
cd vcpkg
31
+
./bootstrap-vcpkg.sh
32
+
```
33
+
34
+
2. **Install Required Libraries**:
35
+
```sh
36
+
./vcpkg install spdlog:x64-windows-static
37
+
./vcpkg install boost-beast:x64-windows-static
38
+
./vcpkg install openssl:x64-windows-static
39
+
```
40
+
41
+
3. **Integrate vcpkg with CMake**:
42
+
Add the following line to your CMake configuration to use vcpkg:
0 commit comments