aklivity / zilla

🦎 A multi-protocol edge & service proxy. Seamlessly interface web apps, IoT clients, & microservices to Apache Kafka® via declaratively defined, stateless APIs.
https://docs.aklivity.io/zilla
Other
524 stars 48 forks source link

Http/1.1 server suspected flow control bug #749

Open attilakreiner opened 7 months ago

attilakreiner commented 7 months ago

Describe the bug In case zilla is set up as an http proxy between an nginx h2 server and a curl http/1.1 client, if response validation is enabled, and the response is invalid, zilla displays an erratic behavior as described below.

To Reproduce Steps to reproduce the behavior:

Prerequisites:

Setup:

error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid;

events { worker_connections 1024; }

http { server { listen 80 http2; }

include       /etc/nginx/mime.types;
default_type  application/octet-stream;

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;

sendfile        on;
#tcp_nopush     on;

#proxy_read_timeout 3600;
#proxy_connect_timeout 3600;
#proxy_send_timeout 3600;
client_body_timeout 3600;
client_header_timeout 3600;
keepalive_timeout  65;

#gzip  on;

include /etc/nginx/conf.d/*.conf;

}

- start up nginx

docker run -p 8080:80 -v :/usr/share/nginx/html:ro -v /nginx.conf:/etc/nginx/nginx.conf --rm --name nginx nginx

- create this zilla configuration file for a http proxy mode with validation enabled:

name: example bindings: north_tcp_server: type: tcp kind: server options: host: 0.0.0.0 port: 7114 exit: north_http_server north_http_server: type: http kind: server exit: south_http_client south_http_client: type: http kind: client options: versions:

One of these cases are happening, ususally in this order: 1) expected case, curl prints:

curl: (18) transfer closed with 5 bytes remaining to read

2) curl hangs, must be stopped with ^C 3) curl displays an error message:

* Excess found in a read ...
* Closing connection

4) zilla crashes, with an AssertionError with a stack trace like this:

Caused by: java.lang.AssertionError
    at io.aklivity.zilla.runtime.binding.http/io.aklivity.zilla.runtime.binding.http.internal.stream.HttpClientFactory$HttpExchange.onResponseWindow(HttpClientFactory.java:4941)
    at io.aklivity.zilla.runtime.binding.http/io.aklivity.zilla.runtime.binding.http.internal.stream.HttpClientFactory$HttpExchange.onApplication(HttpClientFactory.java:4569)
    at io.aklivity.zilla.runtime.binding.http/io.aklivity.zilla.runtime.binding.http.internal.stream.HttpClientFactory$HttpClientPool.lambda$newStream$2(HttpClientFactory.java:2086)
    at io.aklivity.zilla.runtime.engine/io.aklivity.zilla.runtime.engine.internal.registry.EngineWorker.handleReadReply(EngineWorker.java:1276)

Expected behavior The curl command pointed out above should consistently result in the expected case (1) as described above.

Additional context We have investigated this issue with @akrambek and concluded that this is most likely a flow control bug in the http/1.1 server.

The issue only appears in the case zilla client -> nginx use h2 and curl -> zilla server use http/1.1.

attilakreiner commented 7 months ago
Screenshot 2024-01-22 at 16 55 44

May or may not be related... I bumped into this other issue where the onReponseBegin in the exchange crashed on the highlighted assert where acknowledge was 702 and responseAck was 0.