Response message:Server response should contain 'Connection' header with value 'Upgrade'

Issue #171 new
Former user created an issue

Hi, I am facing the issue "Response message: Server response should contain 'Connection' header with value 'Upgrade'" when trying to open the web socket connection.

I have followed your socket.io-chatserversample.jmx, the initial HTTP Request was successful but WebSocket open connection fails - response body and response headers both are empty.

can you please help me to understand and fix this issue.

Comments (7)

  1. Peter Doornbosch repo owner
    • did you use “option 1” or “option 2”?
    • in the results for “Websocket Open Connection”, select “Request” tab → “Request body” tab. It should display the Connect URL, what is its value?

  2. Stalin Gunasekaran N

    I have found the issue in file WebSocketClient.java line number 500

    if (! "upgrade".equals(getLowerCase(serverHeaders.get("Connection"))))  // According to RFC 6455 section 4.1, client must match case-insensative
          throw new HttpUpgradeException("Server response should contain 'Connection' header with value 'Upgrade'");*/
    

    in my case the key 'Connection' has value “Upgrade, Upgrade”

    as we check for only “upgrade” it throws the exception

    which is added from the if block

    do {
        line = httpReader.readLine();
        log.debug("<< " + line);
        if (line != null) {
            String[] values = line.split(":", 2);
            if (values.length > 1) {
                String key = values[0];
                String value = values[1].trim();
                if (serverHeaders.containsKey(key)) {
                    log.debug("-- if SH" + key + "," + value);
                    serverHeaders.put(key, serverHeaders.get(key) + ", " + value);
                } else {
                    log.debug("-- else SH" + key + "," + value);
                    serverHeaders.put(key, value);
                }
            }
        }
    }
    while (line != null && line.trim().length() > 0);  
    

  3. Peter Doornbosch repo owner

    Well, you’re right that the plugin does not handle multi-value header correctly, but a server sending a connection header with twice the same value sounds as a bug as well; at least it is quite silly.

  4. Stalin Gunasekaran N

    @Ewelina Kalemba

    Hi, I have changed the below line to check for “contains” instead of “equals”

    WebSocketClient.java line number 500

    from

    if (! "upgrade".equals(getLowerCase(serverHeaders.get("Connection"))))

    to

    if(!(getLowerCase(serverHeaders.get("Connection"))).contains(“upgrade”))

  5. Log in to comment