PY

etesync_etebase_server_fastapi_routers_websocket.py

Attached EteSync `websocket_endpoint` is never called on Debian 13 apache2 while using `collectionManager.itemManager.subscribeChanges`. How to solve this issue?
Aug 16, 2:29pm

To diagnose why the websocket_endpoint is never called in your EteSync setup on Debian 13 with Apache2, we need to verify a few things. The issue likely stems from one of the following areas:


1. WebSocket Configuration in Apache2

Apache2 does not natively support WebSocket connections. You need to:

  • Enable mod_proxy_wstunnel to proxy WebSocket connections to your backend (e.g., FastAPI).
  • Ensure your Apache2 configuration includes the correct ProxyPass directives for WebSocket routes.

Example Apache2 Configuration:

apache
<VirtualHost *:80>
    ServerName yourdomain.com

    # Proxy for HTTP
    ProxyPass / http://localhost:8000/
    ProxyPassReverse / http://localhost:8000/

    # Proxy for WebSocket
    ProxyPass /ws ws://localhost:8000/ws
    ProxyPassReverse /ws ws://localhost:8000/ws
</VirtualHost>
  • Restart Apache2 after making changes:
    bash
    sudo systemctl restart apache2

2. FastAPI WebSocket Endpoint

Ensure your FastAPI WebSocket endpoint is correctly defined and accessible. For example:

python
from fastapi import FastAPI, WebSocket

app = FastAPI()

@app.websocket("/ws")
async def websocket_endpoint(websocket: WebSocket):
    await websocket.accept()
    while True:
        data = await websocket.receive_text()
        await websocket.send_text(f"Message: {data}")
  • Verify the endpoint is registered in your FastAPI app and matches the path used in Apache2 (/ws in this example).

3. EteSync Client-Side Subscription

Check how collectionManager.itemManager.subscribeChanges is implemented:

  • Ensure it is connecting to the correct WebSocket URL (e.g., ws://yourdomain.com/ws).
  • Verify that the client-side code is not failing silently (e.g., due to CORS, network issues, or incorrect URLs).

4. Debugging Steps

  1. Check Apache2 Logs: Look for errors in /var/log/apache2/error.log or /var/log/apache2/access.log.

  2. Test WebSocket Directly: Use a tool like wscat to test the WebSocket connection:

    bash
    wscat -c ws://localhost:8000/ws

    If this fails, the issue is likely with the FastAPI server or Apache2 proxy.

  3. Verify FastAPI Logs: Check if the FastAPI server logs show any incoming WebSocket connections.

  4. Check Browser Console: If the client is a web app, inspect the browser's console for WebSocket errors (e.g., WebSocket connection failed).


5. Firewall and Ports

  • Ensure port 8000 (or the port your FastAPI server runs on) is open and not blocked by a firewall.
  • If using HTTPS, ensure the WebSocket URL uses wss:// and the SSL certificate is valid.

6. EteSync-Specific Considerations

  • If EteSync uses a custom WebSocket path or headers, ensure Apache2 is configured to forward them.
  • Verify that subscribeChanges is being called with the correct parameters and that the EteSync server is running.

Next Steps

If you share:

  • Your Apache2 configuration,
  • The FastAPI WebSocket endpoint code,
  • The client-side code for subscribeChanges,
  • Any error logs from Apache2 or FastAPI,

I can help pinpoint the exact issue. Would you like to start with any of these?

Aug 16, 2:29pm

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Vibe can make mistakes. Check answers. Learn more