No response received for the FIRST REQUEST ONLY, net::ERR_CONNECTION_CLOSED,curl: (16) Error in the HTTP2 framing layer

I am in need of your help desperately
Descrption-:Iam using traefik as reverse proxy, I also have api- spring cloudgateway that routes to different serivces and for front end to serve static files etc iamusing ngnix,

Problem Description-: Iam requesting for the otp end point
dev.cpp com/api/otp/auth/requestOtp
the otp gets generated correctly and iam able to receive the otp at the backend but the ISSUE here is
Iam unable to receive the 200 OK response for the FIRST REQUEST ONLY.(Meaning when i request for /requestOtp end point for the first time after starting my otp-srvc applcaition iam unable to recieve the 200 OK response, from the subsequent request it is working absolutely fine)
From the SECOND request onwards iam able to get the resposne correctly.

An error occurred: Sorry, new users can only put 4 links in a post.
Could you please tell me what to do in order to recieve the response 200 OK
in the first request after I start my opt service appclaition. :folded_hands:

Below is my docker-compose.traefik.yml
services:
traefik:
build:
context: .
dockerfile: Dockerfile.traefik-curl
image: chaturveda/traefik-with-curl:latest
container_name: cpp-traefik
command:
- "--entrypoints.websecure.address=:443"
- "--entrypoints.websecure.http.tls=true"
- "--providers.docker=true"
- "--providers.file.filename=/etc/traefik/dynamic_conf.yml"
- "--api.dashboard=true"
- "--accesslog=true"
- "--accesslog.format=json"
- "--log.level=DEBUG"
ports:
- "443:443"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./certs:/certs"
- "./traefik/dynamic_conf.yml:/etc/traefik/dynamic_conf.yml:ro"
labels:
- "traefik.enable=true"
- "traefik.http.routers.dashboard.rule=Host(dev.cpp com)"
- "traefik.http.routers.dashboard.entrypoints=websecure"
- "traefik.http.routers.dashboard.tls=true"
- "traefik.http.routers.dashboard.service=api@internal"
networks:
- cpp_network

networks:
cpp_network:
external: true

Below is Doker file for my traefik

traefik with curl support for debugging

FROM traefik:v2.11.1

Add curl via Alpine package manager

RUN apk add --no-cache curl

This is how Iam using traefik in gateway
labels:
- "traefik.enable=true"
- "traefik.http.routers.gateway.rule=Host(dev.cpp com) && PathPrefix(/api)"
- "traefik.http.routers.gateway.entrypoints=websecure"
- "traefik.http.routers.gateway.tls=true"
- "traefik.http.services.gateway.loadbalancer.server.port=8085"

For Detilaed analysis using curl command below are the deitlas-:

$ docker exec -it dockerprojectcpp-traefik ash -c "curl -vk
dev.cpp com/api/otp/auth/requestOtp -H "Host: dev.cpp com" -H "Content-Type: application/json" --data '{"phone":"91**********","termsAccepted":true}'"

  • Host dev.cpp:443 was resolved.
  • IPv6: (none)
  • IPv4: *****
  • Trying *****...
  • ALPN: curl offers h2,http/1.1
  • TLSv1.3 (OUT), TLS handshake, Client hello (1):
  • TLSv1.3 (IN), TLS handshake, Server hello (2):
  • TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
  • TLSv1.3 (IN), TLS handshake, Certificate (11):
  • TLSv1.3 (IN), TLS handshake, CERT verify (15):
  • TLSv1.3 (IN), TLS handshake, Finished (20):
  • TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
  • TLSv1.3 (OUT), TLS handshake, Finished (20):
  • SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256 / ***** / RSASSA-PSS
  • ALPN: server accepted h2
  • Server certificate:
  • subject: O=mkcert development certificate; OU=RAMUGUPRA\ramu@ramugupra (ramugupra)* start date: May 29 08:06:08 2025 GMT
  • expire date: Aug******* GMT
  • issuer: O=mkcert development CA; OU=RAMUGUPRA\ramu@ramugupra (ramugupra); CN=mkcert RAMUGUPRA\ramu@ramugupra (ramugupra)
  • SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
  • Certificate level 0: Public key type RSA (/ Bits/secBits), signed using ***********
  • Connected to dev.cpp com (******) port 443
  • using HTTP/2
  • [HTTP/2] [1] OPENED stream for dev.cpp.com/api/otp/auth/requestOtp
  • [HTTP/2] [1] [:method: POST]
  • [HTTP/2] [1] [:scheme: https]
  • [HTTP/2] [1] [:authority: dev.cpp com]
  • [HTTP/2] [1] [:path: /api/otp/auth/requestOtp]
  • [HTTP/2] [1] [user-agent: curl/****]
  • [HTTP/2] [1] [accept: /]
  • [HTTP/2] [1] [content-type: application/json]
  • [HTTP/2] [1] [content-length: 45]

POST /api/otp/auth/requestOtp HTTP/2
Host: dev.cpp com
User-Agent: curl/****

Accept: /
Content-Type: application/json
Content-Length: 45

  • upload completely sent off: 45 bytes
  • TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
  • TLSv1.3 (IN), TLS alert, close notify (256):
  • closing connection #0
    curl: (16) Error in the HTTP2 framing layer

Place 3 backticks before and after code/config to make it more readable and preserve spacing, which is important in yaml.