Is it possible to disable HTTP/2 for the netty ser...
# ktor
t
Is it possible to disable HTTP/2 for the netty server engine? I have a legacy application and HTTP/2 brings out a bug in Chrome (an XHR request is in pending status, it does not arrive to the server).
j
AFAIK it is the client that controls which http version to use
t
That's the problem, Chrome wants HTTP/2 but then it does not work properly. In Firefox everything is OK. When I use the same Javascript with a non-Ktor HTTP/1.1 server, it works in Chrome as well.
j
What is the error you are receiving by XHR?
t
There is no error, it is in "pending" forever.
And the Ktor log for the requests above.
j
XHR Requests in browser are supposed to support HTTP/2 as far as I know, so it is weird it gets stuck at pending
Do you have a service worker that intercepts requests?
t
No, it is a simple XMLHttpRequest, no workers. This is a quite old legacy application. Thanks for the answers btw.
j
Are you able to share the code that calls the endpoint?
t
This is what I have. xmlhttp is a new XMLHttpRequest.
Copy code
this.send = function(url, body, handler) {
        try {
            responseHandler = handler;
            xmlhttp.open("post", url, true);
            for (var i = 0; i < headers.length; i++) {
                var header = headers[i];
                xmlhttp.setRequestHeader(header.name, header.value);
            }

            if (<http://hx.ie|hx.ie>)
                xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");

            xmlhttp.onreadystatechange = this.handleResponse;
            xmlhttp.send(body);
        } catch (err) {
            hx.doError("Message error", null, err);
        }
    }
j
Untitled.js
I don't see anything instantly wrong with that.. Chances are there might be something blocking the thread.
Do you get the same issue in Chromium?
t
Haven't tried to be honest. But, you've just gave me an idea, I'll try to add a small delay on the server side so the order of answers will be different.
Hm, I've added an nxign proxy between Ktor and Chrome and now it works. Something is fishy in the Ktor-Netty-SSL-HTTP/2 setup.