# Server Connection Troubleshooting

## Issue: Search page shows "Not connected to the server"

### Quick Fix Steps:

1. **Restart the server**:
   ```bash
   cd server
   python app.py
   ```

2. **Install missing dependencies** (if you see import errors):
   ```bash
   cd server
   pip install flask-limiter==3.5.0 flask-compress==1.14
   ```

3. **Test server connectivity**:
   ```bash
   python test_server_connection.py
   ```

### What Changed:
- Added rate limiting (flask-limiter)
- Added response compression (flask-compress)
- Enhanced error boundaries
- Made imports gracefully fallback if dependencies missing

### Expected Server Startup Messages:
```
INFO - Compression enabled
INFO - Rate limiting enabled
INFO - Running on http://0.0.0.0:5140
```

Or if dependencies are missing:
```
WARNING - flask-limiter not installed - rate limiting disabled
WARNING - flask-compress not installed - compression disabled
INFO - Running on http://0.0.0.0:5140
```

### Common Issues:

1. **Port 5140 already in use**:
   - Kill existing server process
   - Or change port in server/app.py

2. **Missing dependencies**:
   - Install from requirements.txt: `pip install -r requirements.txt`

3. **Python environment issues**:
   - Make sure you're in the correct virtual environment
   - Check Python version compatibility

### Testing Connection:

1. **HTTP Test**: Visit http://localhost:5140/api/test-spotify
2. **SocketIO Test**: Use the test script provided
3. **Frontend Test**: Check browser console for connection errors

### Performance Features Status:
- ✅ Search debouncing (already working)
- ✅ Error boundaries (added)
- ⚠️ Rate limiting (needs flask-limiter)
- ⚠️ Compression (needs flask-compress)
- ✅ Image lazy loading (already working)

The server will work without the new dependencies, but performance improvements will be limited.