74 lines
1.8 KiB
Markdown
74 lines
1.8 KiB
Markdown
# Gateway Service
|
|
|
|
WebSocket API gateway for vehicle (TRex), HMI, and mobile app connections.
|
|
|
|
## What it does
|
|
|
|
- Authenticates WebSocket connections via JWT
|
|
- Routes messages to Kafka topics
|
|
- Manages connection state in Redis
|
|
- Serves AsyncAPI docs
|
|
|
|
## Ports
|
|
|
|
| Port | Purpose |
|
|
|------|---------|
|
|
| 8077 | HTTP/WebSocket |
|
|
| 11011 | Health check |
|
|
|
|
## WebSocket Endpoints
|
|
|
|
| Endpoint | Purpose | User-Agent |
|
|
|----------|---------|------------|
|
|
| `/session` | Vehicle (TRex) and HMI connections | `Fisker Ocean T.Rex x.x.x.x` or `HMI x.x.x.x` |
|
|
| `/secret_mobile` | Mobile app connections | `Mobile x.x.x` or `iOS x.x.x` or `Android x.x.x` |
|
|
|
|
## API Documentation
|
|
|
|
AsyncAPI specs available at `/docs/`:
|
|
- `/docs/asyncapi_mobile.yaml` - Mobile API
|
|
- `/docs/asyncapi_hmi.yaml` - HMI API
|
|
- `/docs/asyncapi_trex.yaml` - T-Rex API
|
|
- `/docs/index.html` - Interactive UI
|
|
|
|
## Testing WebSocket Connections
|
|
|
|
Install websocat:
|
|
```bash
|
|
brew install websocat
|
|
```
|
|
|
|
Test mobile endpoint:
|
|
```bash
|
|
# Connect to mobile websocket
|
|
websocat -H="User-Agent: Mobile 1.0.0" wss://gateway.mini.cloud.fiskerinc.com/secret_mobile
|
|
|
|
# Send verify message (after connecting)
|
|
{"handler":"verify","data":{"token":"<jwt_token>"}}
|
|
```
|
|
|
|
Test vehicle endpoint (requires VIN in SSL cert or header):
|
|
```bash
|
|
websocat -H="User-Agent: Fisker Ocean T.Rex 1.0.0.0 ABC123" \
|
|
-H="X-VIN: YH7DR1EA1PA000001" \
|
|
wss://gateway.mini.cloud.fiskerinc.com/session
|
|
```
|
|
|
|
## Build
|
|
|
|
```bash
|
|
# From cloud-services root
|
|
docker build --platform linux/arm64 -t gateway:latest -f services/gateway/Dockerfile .
|
|
```
|
|
|
|
## Configuration
|
|
|
|
See `deploy/base/config.env` for all environment variables.
|
|
|
|
Key settings:
|
|
- `KAFKA_HOSTS` - Kafka bootstrap servers
|
|
- `REDIS_HOST/PORT` - Redis for session state
|
|
- `JWK_URL` - JWKS endpoint for JWT validation
|
|
- `DOCS` - Path to docs directory (default: `/docs`)
|
|
- `LOG_LEVEL` - debug, info, warn, error
|