TooTallNate/Java-WebSocket · error · InvalidHandshakeException
Invalid status line received
Error message
Invalid status line received: %s Status line: %s
What it means
This guard fires in Draft.translateHandshakeHttpServer when the third token of the request's first line is not 'HTTP/1.1'. The WebSocket handshake (RFC 6455) requires HTTP/1.1; a request line ending in HTTP/1.0 or any other protocol token cannot carry the required upgrade semantics, so the handshake is rejected with InvalidHandshakeException. The faulty input is a client request whose status line declares a protocol/version other than HTTP/1.1.
Solutions
- Ensure the connecting client uses HTTP/1.1 for the upgrade request (WebSocket requires it, not HTTP/1.0)
- Check for old HTTP client libraries, embedded devices, or proxies downgrading the request to HTTP/1.0
- Verify the request line is well formed with exactly three tokens: METHOD resource HTTP/1.1
- If supporting legacy clients is required, upgrade them or terminate the connection gracefully at the plain-HTTP layer instead
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/main/java/org/java_websocket/drafts/Draft.java:149 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of TooTallNate/Java-WebSocket@afeacbf8c0 (2026-09-09).
Data as JSON: /api/errors/7fd2a28322afb281.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/org/java_websocket/drafts/Draft.java:149
return handshake;
}
/**
* Checking the handshake for the role as server
*
* @param firstLineTokens the token of the first line split as as an string array
* @param line the whole line
* @return a handshake
*/
private static HandshakeBuilder translateHandshakeHttpServer(String[] firstLineTokens,
String line) throws InvalidHandshakeException {
// translating/parsing the request from the CLIENT
if (!"GET".equalsIgnoreCase(firstLineTokens[0])) {
throw new InvalidHandshakeException(String
.format("Invalid request method received: %s Status line: %s", firstLineTokens[0], line));
}
if (!"HTTP/1.1".equalsIgnoreCase(firstLineTokens[2])) {
throw new InvalidHandshakeException(String
.format("Invalid status line received: %s Status line: %s", firstLineTokens[2], line));
}
ClientHandshakeBuilder clienthandshake = new HandshakeImpl1Client();
clienthandshake.setResourceDescriptor(firstLineTokens[1]);
return clienthandshake;
}
/**
* Checking the handshake for the role as client
*
* @param firstLineTokens the token of the first line split as as an string array
* @param line the whole line
* @return a handshake
*/
private static HandshakeBuilder translateHandshakeHttpClient(String[] firstLineTokens,
String line) throws InvalidHandshakeException {
// translating/parsing the response from the SERVER
if (!"101".equals(firstLineTokens[1])) {View on GitHub (pinned to afeacbf8c0)