Skip to content

CONNECT-UDP in forwarding proxy mode resets stream and fails to send HTTP Datagrams #34836

Closed

Description

@jeongseokson

Title: CONNECT-UDP in forwarding proxy mode resets stream and fails to send HTTP Datagrams

Description:
When Envoy is configured as a CONNECT-UDP forwarding proxy, where it forwards the requests to upstream and HTTP Datagrams without terminating HTTP, it fails to forward the HTTP Datagrams and resets the stream.

Repro steps:
Use the example config in configs/proxy_connect_udp_http3_downstream.yaml to run a CONNECT-UDP forwarding proxy, and send CONNECT-UDP request and subsequent HTTP Datagrams to it.

Admin and Stats Output:
See #33775

Config:
configs/proxy_connect_udp_http3_downstream.yaml

Logs:
See #33775

Call Stack:
See #33775

Activity

  1. added
    triage
    on Jun 21, 2024
  2. jeongseokson commented on Jun 21, 2024

    @jeongseokson
    ContributorAuthor
  3. added and removed
    triage
    on Jun 21, 2024
  4. github-actions commented on Jul 21, 2024

    @github-actions

    This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

  5. added
    stale
    on Jul 21, 2024
  6. github-actions commented on Jul 28, 2024

    @github-actions

    This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.

  7. jeongseokson commented on Aug 26, 2024

    @jeongseokson
    ContributorAuthor

    @RyanTheOptimist Hi Ryan, can you reopen it and mark it as no stale? I am currently working on this issue.

  8. DavidSchinazi commented on Aug 26, 2024

    @DavidSchinazi
    Contributor

    /nostalebot

  9. added
    no stalebot
    on Aug 26, 2024
  10. DavidSchinazi commented on Aug 26, 2024

    @DavidSchinazi
    Contributor

    @RyanTheOptimist while you're reopening this one, please also close #33775 - thanks!

  11. removed
    stale
    on Aug 26, 2024
  12. RyanTheOptimist commented on Aug 26, 2024

    @RyanTheOptimist
    Contributor

    @RyanTheOptimist while you're reopening this one, please also close #33775 - thanks!

    Done!

  13. jeongseokson commented on Sep 23, 2024

    @jeongseokson
    ContributorAuthor

    Thanks for your patience, @Bfarkiani. We identified the issue thanks to your report. The fix has been merged into the main branch, so could you please try the forwarding mode again on your end after fetching the main branch? I was able to successfully make the two Envoy proxies (one for forwarding and the other for terminating) receive an HTTP/3 response from google.com using masque_client locally. Please let me know if you run into any problems.

  14. Bfarkiani commented on Sep 26, 2024

    @Bfarkiani

    Dear @jeongseokson . Thank you for your help. I tested with the following configs:

    Client

    static_resources:
      listeners:
      - name: listener_0
        address:
          socket_address:
            protocol: UDP
            address: 0.0.0.0
            port_value: 10000
        udp_listener_config:
          quic_options: {}
          downstream_socket_config:
            prefer_gro: true
        filter_chains:
        - transport_socket:
            name: envoy.transport_sockets.quic
            typed_config:
              '@type': type.googleapis.com/envoy.extensions.transport_sockets.quic.v3.QuicDownstreamTransport
              downstream_tls_context:
                common_tls_context:
                  tls_certificates:
                  - certificate_chain:
                      filename: /etc/envoy/example.com.crt
                    private_key:
                      filename: /etc/envoy/example.com.key
          filters:
          - name: envoy.filters.network.http_connection_manager
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
              codec_type: HTTP3
              stat_prefix: ingress_http
              access_log:
              - name: envoy.access_loggers.stdout
                typed_config:
                  "@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog                       
              
              route_config:
                name: local_route
                virtual_hosts:
                - name: local_service
                  domains:
                  - "*"
                  routes:
                  - match:
                      connect_matcher:
                        {}
                    route:
                      cluster: cluster_0
              http_filters:
              - name: envoy.filters.http.router
                typed_config:
                  "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
              http3_protocol_options:
                allow_extended_connect: true
              upgrade_configs:
              - upgrade_type: CONNECT-UDP
      clusters:
      - name: cluster_0
        typed_extension_protocol_options:
          envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
            "@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
            explicit_http_config:
              http3_protocol_options:
                allow_extended_connect: true
                quic_protocol_options:
                  # Increase the max packet length for tunneling.
                  # The example value matches the default value used by the MASQUE client in QUICHE.
                  max_packet_length: 1350
        load_assignment:
          cluster_name: cluster_0
          endpoints:
          - lb_endpoints:
            - endpoint:
                address:
                  socket_address:
                    address: 192.168.170.129
                    port_value: 10000
        transport_socket:
          name: envoy.transport_sockets.quic
          typed_config:
            "@type": type.googleapis.com/envoy.extensions.transport_sockets.quic.v3.QuicUpstreamTransport
            upstream_tls_context:
              # SAN of the certs/servercert.pem used for local testing. Update this if using a different certificate.
              sni: example.com
    
    

    Server:

    static_resources:
      listeners:
      - name: listener_0
        address:
          socket_address:
            protocol: UDP
            address: 0.0.0.0
            port_value: 10000
        udp_listener_config:
          quic_options: {}
          downstream_socket_config:
            prefer_gro: true
        filter_chains:
        - transport_socket:
            name: envoy.transport_sockets.quic
            typed_config:
              '@type': type.googleapis.com/envoy.extensions.transport_sockets.quic.v3.QuicDownstreamTransport
              downstream_tls_context:
                common_tls_context:
                  tls_certificates:
                  - certificate_chain:
                      filename: /etc/envoy/example.com.crt
                    private_key:
                      filename: /etc/envoy/example.com.key
          filters:
          - name: envoy.filters.network.http_connection_manager
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
              codec_type: HTTP3
              stat_prefix: ingress_http
              access_log:
              - name: envoy.access_loggers.stdout
                typed_config:
                  "@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog                       
              route_config:
                name: local_route
                virtual_hosts:
                - name: local_service
                  domains:
                  - "*"
                  routes:
                  - match:
                      connect_matcher:
                        {}
                    route:
                      cluster: service_google
                      upgrade_configs:
                      - upgrade_type: CONNECT-UDP
                        connect_config:
                          {}
              http_filters:
              - name: envoy.filters.http.dynamic_forward_proxy
                typed_config:
                  "@type": type.googleapis.com/envoy.extensions.filters.http.dynamic_forward_proxy.v3.FilterConfig
                  dns_cache_config:
                    name: dynamic_forward_proxy_cache_config
                    dns_lookup_family: V4_ONLY          
              - name: envoy.filters.http.router
                typed_config:
                  "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
              http3_protocol_options:
                allow_extended_connect: true
              upgrade_configs:
              - upgrade_type: CONNECT-UDP
      clusters:
      - name: service_google
        type: LOGICAL_DNS
        # Comment out the following line to test on v6 networks
        dns_lookup_family: V4_ONLY
        lb_policy: ROUND_ROBIN
        load_assignment:
          cluster_name: service_google
          endpoints:
          - lb_endpoints:
            - endpoint:
                address:
                  socket_address:
                    address: www.google.com
                    port_value: 443
    

    Command:
    ./masque_client --disable_certificate_verification --allow_unknown_root_cert 127.0.0.1:10000 https://www.google.com

    Client proxy printed:

    [2024-09-26 01:28:26.706][16][info][quic] [external/com_github_google_quiche/quiche/quic/core/tls_server_handshaker.cc:976] No hostname indicated in SNI
    [2024-09-26 01:28:26.723][16][warning][quic_stream] [source/common/quic/http_datagram_handler.cc:62] SendHttpH3Datagram failed: status = MESSAGE_STATUS_SETTINGS_NOT_RECEIVED, drops the Datagram.
    [2024-09-26T01:28:26.718Z] "GET /.well-known/masque/udp/www.google.com/443/ HTTP/3" 101 OM 5439 72019 521 - "-" "-" "700cf726-5f78-4fb9-85fe-e3e2c12f89b5" "www.google.com:443" "192.168.170.129:10000"
    

    Server proxy printed:

    [2024-09-26T01:28:26.722Z] "GET /.well-known/masque/udp/www.google.com/443/ HTTP/3" 200 - 4128 72019 516 - "-" "-" "700cf726-5f78-4fb9-85fe-e3e2c12f89b5" "www.google.com:443" "142.250.191.132:443"

    Command returned with no error and no data. I think it is the expected behavior?

    Thank you.

  15. jeongseokson commented on Sep 27, 2024

    @jeongseokson
    ContributorAuthor

    The access log shows that it returned a 200 status code, so it seems to be working fine. You can pass the --stderrthreshold=0 flag to see the response printed out. Here's the command I used:

    $ ./masque_client --stderrthreshold=0 --disable_certificate_verification 127.0.0.1:10000 https://www.google.com/

  16. Bfarkiani commented on Sep 30, 2024

    @Bfarkiani

    @jeongseokson Yes it works fine. masque_client did not report any error.

    Thank you.

  17. jeongseokson commented on Oct 8, 2024

    @jeongseokson
    ContributorAuthor

    Great! I'm glad it finally worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/udpbugno stalebot

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions