A comprehensive collection of network service implementations for testing and development purposes. This project provides containerized services for various network protocols, making it easy to test DialogChain integrations without requiring actual backend services.
- RTSP Server: Simulates RTSP video streaming with test streams
- HTTP Server: Lightweight REST API server with common endpoints
- gRPC Server: Complete gRPC service with support for different RPC patterns
- WebRTC Server: WebRTC signaling server implementation
- MQTT Broker: MQTT message broker with WebSocket support
- Containerized: Easy deployment with Docker Compose
- Development Ready: Pre-configured for local development and testing
- Docker 20.10.0+
- Docker Compose 2.0.0+
- Make (optional, but recommended)
- Python 3.7+ (for development)
-
Clone the repository:
git clone https://github.com/dialogchain/endpoints.git cd endpoints
-
Start all services:
make up
-
Check service status:
make status
-
Access services:
- HTTP Server: http://localhost:8080
- MQTT Broker: mqtt://localhost:1883
- RTSP Stream: rtsp://localhost:8554/stream
- Port: 8554 (RTSP), 8000 (HTTP)
- Streams: /stream, /test
- Features: H.264 video, AAC audio, authentication support
- Port: 8080
- Endpoints:
GET /api/status
- Service statusPOST /api/echo
- Echo request dataGET /api/stream
- Server-sent events
- Port: 50051
- Services:
- EchoService
- ChatService
- StreamService
- Port: 1883 (MQTT), 8883 (MQTT over SSL), 9001 (WebSocket)
- Topics:
test/topic
- General testingsensors/#
- Sensor datacommands/#
- Command messages
- Port: 8443
- Features:
- WebSocket signaling
- STUN/TURN support
- Multi-room chat
# Test HTTP endpoint
curl http://localhost:8080/api/status
# Publish MQTT message
mosquitto_pub -h localhost -t test/topic -m "Hello, MQTT!"
# View RTSP stream (requires VLC)
vlc rtsp://localhost:8554/stream
import paho.mqtt.client as mqtt
def on_connect(client, userdata, flags, rc):
logger.info(f"Connected with result code {rc}")
client.subscribe("test/topic")
def on_message(client, userdata, msg):
logger.info(f"{msg.topic}: {msg.payload.decode()}")
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect("localhost", 1883, 60)
client.loop_forever()
-
Install development dependencies:
pip install -r requirements-dev.txt
-
Set up pre-commit hooks:
pre-commit install
# Build all services
make build
# Start services in detached mode
make up
# View logs
make logs
# Run tests
make test
# Stop services
make down
# Clean up everything
make clean
- Create a new directory for your service
- Add a
Dockerfile
and any necessary configuration - Update
docker-compose.yml
- Add documentation to this README
- Submit a pull request
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
make lint
make test-coverage
make test-http # Test HTTP server make test-grpc # Test gRPC service make test-mqtt # Test MQTT broker make test-rtsp # Test RTSP server make test-webrtc # Test WebRTC server
### Service Management
```bash
# Start specific service
make -C http up
make -C grpc up
# Stop specific service
make -C http down
make -C grpc down
# View service logs
docker-compose logs -f http
docker-compose logs -f grpc
- Prometheus Metrics:
http://localhost:8000/metrics
(gRPC service) - Health Checks:
- HTTP:
http://localhost:8080/health
- gRPC: Use
grpc_health_probe
tool
- HTTP:
- Ports:
- 8554 (RTSP)
- 8888 (HTTP)
- Test Streams:
rtsp://localhost:8554/stream
rtsp://localhost:8554/test
- Features:
- Simulates video streaming
- HTTP interface for stream management
- Multiple concurrent streams support
- Port: 8080
- Base URL:
http://localhost:8080
- Endpoints:
GET /
- Service statusGET /api/data
- Retrieve sample dataPOST /api/echo
- Echo back request dataGET /api/status/{code}
- Returns specified HTTP status codeGET /api/delay/{seconds}
- Simulates delayed response
- Features:
- JSON request/response support
- CORS enabled
- Request logging
- Ports:
- 50051 (gRPC)
- 8000 (Prometheus metrics)
- Service:
example.Greeter
- Methods:
SayHello
- Simple unary RPCStreamData
- Server streaming RPCClientStream
- Client streaming RPCBidirectionalStream
- Bidirectional streaming RPC
- Features:
- Health check endpoint
- Prometheus metrics
- Reflection enabled
- Graceful shutdown
- Ports:
- 1883 (MQTT)
- 9001 (MQTT over WebSocket)
- Features:
- MQTT 3.1.1 and 5.0 support
- WebSocket interface
- Authentication support
- Topic wildcards
- Port: 8443
- Features:
- WebSocket signaling
- ICE/STUN/TURN support
- Multi-client connections
- Secure WebSocket (WSS) support
# Run all tests
make test
# Run specific service tests
make test-http # Test HTTP endpoints
make test-grpc # Test gRPC service
make test-mqtt # Test MQTT broker
make test-rtsp # Test RTSP server
make test-webrtc # Test WebRTC signaling
# Run tests with coverage report
make test-coverage
# Run linter
make lint
Run all tests:
ansible-playbook -i inventory.ini test.yml
Run specific service tests:
ansible-playbook -i inventory.ini test.yml --tags rtsp
ansible-playbook -i inventory.ini test.yml --tags http
ansible-playbook -i inventory.ini test.yml --tags grpc
ansible-playbook -i inventory.ini test.yml --tags mqtt
ansible-playbook -i inventory.ini test.yml --tags webrtc
endpoints/
βββ grpc/ # gRPC server implementation
β βββ docker/ # Docker configuration
β βββ ansible/ # Ansible test cases
β βββ proto/ # Protocol buffer definitions
βββ http/ # HTTP server
β βββ docker/
β βββ ansible/
βββ mqtt/ # MQTT broker
β βββ docker/
β βββ ansible/
βββ rtsp/ # RTSP server
β βββ docker/
β βββ ansible/
βββ webrtc/ # WebRTC server
βββ docker/
βββ ansible/
- Create a new directory under
endpoints/
- Add the following structure:
new-service/ βββ docker/ β βββ Dockerfile βββ ansible/ β βββ test.yml βββ Makefile
- Update root files:
- Add service to
docker-compose.yml
- Update root
Makefile
with build/test commands - Add test task to
test.yml
- Add service to
# Get service status
curl http://localhost:8080/
# Get sample data
curl http://localhost:8080/api/data
# Test different status codes
curl http://localhost:8080/api/status/200
curl http://localhost:8080/api/status/404
# Test delayed response (5 seconds)
curl http://localhost:8080/api/delay/5
Using mosquitto
client:
# Subscribe to a topic
mosquitto_sub -h localhost -t "test/topic"
# Publish a message
mosquitto_pub -h localhost -t "test/topic" -m "Hello MQTT"
import grpc
import example_pb2
import example_pb2_grpc
channel = grpc.insecure_channel('localhost:50051')
stub = example_pb2_grpc.GreeterStub(channel)
response = stub.SayHello(example_pb2.HelloRequest(name='World'))
logger.info(f"gRPC response: {response.message}")
HTTP_PORT
: Port to listen on (default: 8080)LOG_LEVEL
: Logging level (debug, info, warning, error)
MQTT_PORT
: MQTT port (default: 1883)WS_PORT
: WebSocket port (default: 9001)ANONYMOUS
: Allow anonymous access (default: true)
RTSP_PORT
: RTSP server port (default: 8554)HTTP_PORT
: HTTP interface port (default: 8888)
- Prometheus Metrics: Available at
http://localhost:8000/metrics
for gRPC service - Docker Logs: View logs for individual services using
docker logs <container-name>
- Health Checks:
- HTTP:
http://localhost:8080/health
- gRPC: Use
grpc_health_probe
tool
- HTTP:
-
Port Conflicts
- Check if required ports are available
- Customize ports in
docker-compose.yml
if needed
-
Service Not Starting
- Check logs:
docker-compose logs <service_name>
- Verify Docker is running:
docker ps
- Check logs:
-
Connection Refused
- Ensure service is running
- Check firewall settings
- Verify host and port configuration
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
# Install development dependencies
pip install -r requirements-dev.txt
# Run linter
make lint
# Run tests with coverage
make test-coverage
This project is licensed under the terms of the MIT License. See the LICENSE file for details.
Service | Requests/s | Latency (avg) |
---|---|---|
HTTP | 15,000 | 2.1ms |
gRPC | 22,000 | 1.4ms |
MQTT | 50,000+ | <1ms |
Benchmarks performed on Intel i7-9700K, 32GB RAM
Stop and remove all containers, networks, and volumes:
make down
make clean # Removes built images
This project is licensed under the terms of the MIT License. See the LICENSE file for details. make clean