aiortc / aioquic

QUIC and HTTP/3 implementation in Python
BSD 3-Clause "New" or "Revised" License
1.66k stars 236 forks source link

Issues connecting via Cronet -> demo:app #70

Closed pablogranolabar closed 4 years ago

pablogranolabar commented 4 years ago

Hi!

Thanks again for your work on this project. I've been setting up a test environment here, to experiment with Android + Cronet HTTP/3 libs for a mobile app.

I am simply using http3_server.py with the demo:app ASGI module, but cannot get Cronet to even negotiate a connection. Here is the error:

Exception in CronetUrlRequest: net::ERR_QUIC_PROTOCOL_ERROR, ErrorCode=10, InternalErrorCode=-356, Retryable=false, QuicDetailedErrorCode=25

Here's the relevant Cronet code:

private void callCronet() {
        CronetEngine.Builder myBuilder = new CronetEngine.Builder(this);
        cronetEngine = myBuilder
                .addQuicHint("quic.example.com", 8443, 8443)
                .enableHttpCache(CronetEngine.Builder.HTTP_CACHE_IN_MEMORY, 100 * 1024)
                .enableHttp2(true)
                .enableQuic(true)
                .build();

        Executor executor = Executors.newSingleThreadExecutor();
        UrlRequest.Callback callback = new MyUrlRequestCallback();
        UrlRequest.Builder builder = cronetEngine.newUrlRequestBuilder("https://quic.example.com:8443", callback, executor);
        UrlRequest urlRequest = builder.build();
        urlRequest.getStatus(new UrlRequest.StatusListener() {
            @Override
            public void onStatus(int status) {
                Log.e(TAG, status + " ");
            }
        });
        urlRequest.start();
    }

    private void callQuicCronet() {
        CronetEngine.Builder myBuilder = new CronetEngine.Builder(this);
        cronetEngine = myBuilder
                .enableHttpCache(CronetEngine.Builder.HTTP_CACHE_IN_MEMORY, 100 * 1024)
                .enableHttp2(true)
                .enableQuic(true)
                .addQuicHint("quic.tech", 8443, 8443)
                .build();

        Executor executor = Executors.newSingleThreadExecutor();
        UrlRequest.Callback callback = new MyUrlRequestCallback();
        UrlRequest.Builder builder = cronetEngine.newUrlRequestBuilder("https://quic.tech:8443", callback, executor);
        UrlRequest urlRequest = builder.build();
        urlRequest.getStatus(new UrlRequest.StatusListener() {
            @Override
            public void onStatus(int status) {
                Log.e(TAG, status + " ");
            }
        });
        urlRequest.start();
    }

We are able to connect without issue to the public QUIC endpoints above; for this local setup we have signed Let's Encrypt certs and are using the following command line to serve a one line index.html from examples/htdocs:

python3 examples/http3_server.py --certificate certs/fullchain1.pem --private-key certs/privkey1.pem --host quic.example.com --port 8443 -v -q quiclog "demo:app"

Any ideas?

Thanks in advance!

jlaine commented 4 years ago

I have zero experience with cronet, so I'm not going to be of much help regarding your custom code. Before going any further I suggest you try connecting to the following public servers using the same code:

https://bagder.github.io/HTTP3-test/

If the failure is truly specific to aioquic I'd be happy to look into it, otherwise I'd say the problem lies elsewhere.

pablogranolabar commented 4 years ago

Thanks jlaine, I'll try that next!

pablogranolabar commented 4 years ago

Ok, so with our current Cronet setup we've been able to successfully test each of these endpoints listed on the badger.github.io site, all with successful responses. So it looks like it's something I've setup wrong on the aioquic side instead of Cronet on Android.

I am sniffing traffic and see it coming in on the ingress side, but no response from aioquic in return. So there is no debugging information even showing up in http3_server.py verbose logging or the QUIC protocol logs themselves.

pablogranolabar commented 4 years ago

Hi again jlaine,

We still haven't been able to figure out this issue in connecting to aioquic, and our Cronet client connects without issue to all of the endpoints @ https://bagder.github.io/HTTP3-test/.

Any ideas? Is there a public endpoint for aioquic that we can test against as well, to try to figure out the issue? Thanks in advance

jlaine commented 4 years ago

If you have tested all the endpoints in the linked page, you've already successfully tested two endpoints based on aioquic:

pablogranolabar commented 4 years ago

Thanks jlaine. Would it be possible to share the command line options / configuration for those endpoints?

jlaine commented 4 years ago

I can only speak for quic.aiortc.org which runs:

python examples/http3_server.py --certificate demo/ssl_cert.pem --private-key demo/ssl_key.pem --port 443 --quic-log examples/htdocs/logs

VernonPerry commented 4 years ago

Thanks jlaine. We've got a different approach for Android that I am exploring today, I will keep you posted with developments. Thanks for your help.