# Fix WebSocket Connection Error

## Problem
```
TypeError: create_connection() got an unexpected keyword argument 'additional_headers'
```

## Root Cause
- System Python 3.8 was using `websockets==12.0` (old version)
- The code was using `additional_headers` parameter which isn't supported in websockets 10.0-13.x
- For websockets 10.0-13.x, you need to use `extra_headers` (list of tuples) instead

## Solution Applied

### 1. Upgraded websockets
```bash
/usr/bin/python3 -m pip install --upgrade websockets
# Upgraded from 12.0 to 13.1
```

### 2. Updated Code with Fallback
The code now tries `additional_headers` first (for websockets 14.0+), then falls back to `extra_headers` (for websockets 10.0-13.x).

## Verification

After the fix, restart the service:

```bash
sudo systemctl restart websocket_api.service
sudo systemctl status websocket_api.service
```

## WebSocket Version Compatibility

| WebSocket Version | Header Parameter | Format |
|-------------------|------------------|--------|
| 10.0 - 13.x | `extra_headers` | List of tuples: `[("key", "value")]` |
| 14.0+ | `additional_headers` | Dict: `{"key": "value"}` |

## Current Status
- ✅ Websockets upgraded to 13.1
- ✅ Code updated with fallback support
- ✅ Should work with both old and new websockets versions

## Test the Fix

```bash
# Check service status
sudo systemctl status websocket_api.service

# View logs
sudo journalctl -u websocket_api.service -f

# Test a WebSocket connection
# The error should be gone now
```

