W
Wasp3mo ago
cmilazzo

WebSocket connection to 'wss://www.hatchmo.com/?token=cyXEuSJHPtqZ' failed: Error during WebSocket h

WebSocket connection to 'wss://www.<domain>.com/?token=cyXEuSJHPtqZ' failed: Error during WebSocket handshake: Unexpected response code: 200 createConnection @ client:802
2 Replies
kapa.ai
kapa.ai3mo ago
Hi @cmilazzo. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error message:
WebSocket connection to 'wss://www.<domain>.com/?token=cyXEuSJHPtqZ' failed: Error during WebSocket handshake: Unexpected response code: 200
WebSocket connection to 'wss://www.<domain>.com/?token=cyXEuSJHPtqZ' failed: Error during WebSocket handshake: Unexpected response code: 200
indicates that the WebSocket handshake is failing because the server is responding with HTTP status code 200, instead of the expected 101 (Switching Protocols) required for a successful WebSocket upgrade. Based on the Wasp documentation, Wasp uses Socket.IO for WebSockets and handles much of the setup for you, including CORS and URL configuration. However, this error typically means that the WebSocket endpoint is not being handled by a WebSocket server, but rather by a regular HTTP server or a misconfigured proxy. Possible causes and things to check: 1. WebSocket Server Not Running or Not Exposed:
Ensure that your Wasp app has WebSockets enabled in your .wasp file and that the server is running and accessible at the expected endpoint. The configuration should look like this:
app todoApp {
// ...
webSocket: {
fn: import { webSocketFn } from "@src/webSocket",
autoConnect: true, // optional, default: true
},
}

app todoApp {
// ...
webSocket: {
fn: import { webSocketFn } from "@src/webSocket",
autoConnect: true, // optional, default: true
},
}

See docs for details. 2. Proxy or Hosting Configuration:
If you are deploying behind a proxy (like Nginx, Apache, or a cloud provider), make sure it is configured to support WebSocket upgrades. If the proxy does not forward the Upgrade and Connection headers, or if it routes WebSocket requests to the wrong backend, you will get this error. 3. Correct Port and Protocol:
Make sure the client is connecting to the correct port and protocol (wss:// for secure, ws:// for insecure). If you are using a service like ngrok or a custom domain, ensure the WebSocket server is accessible at the public URL. 4. Server/Client Environment Variables:
If you are using environment variables to set API or WebSocket URLs (e.g., REACT_APP_API_URL), ensure they are set correctly for your deployment environment. There are examples in the community where setting these incorrectly led to connection issues see this Discord thread. Summary:
This is not a Wasp-specific error, but a general WebSocket deployment/configuration issue. The Wasp docs do not provide explicit troubleshooting steps for this error, but the above points are the most common causes based on how Wasp integrates Socket.IO and expects the server to be set up. If you need more specific help, please provide details about your deployment setup (hosting provider, proxy configuration, etc.), and check that your WebSocket server is running and accessible at the expected endpoint. If you are running locally and using a tool like ngrok, make sure both the client and server are properly forwarded and that your environment variables point to the correct URLs, as discussed in the community here. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @cmilazzo, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Vinny (@Wasp)
Vinny (@Wasp)3mo ago
Can you provide some more context here? @cmilazzo

Did you find this page helpful?