dev-tunnels icon indicating copy to clipboard operation
dev-tunnels copied to clipboard

Server Sent Event (SSE) request Nginx 504 Gateway Time-out

Open bjsmiley opened this issue 8 months ago • 2 comments
trafficstars

Normal http requests work but if it is a SSE response, my browser/curl shows the request as pending for 15 minutes and then the request finishes with a 504 Gateway Time-out error response from nginx.

Steps to reproduce:

devtunnel create loyal-search-poc -a -e 12d
devtunnel port create loyal-search-poc -p 8000 --protocol http
devtunnel host loyal-search-poc
uv run fastapi run --host localhost poc.py
curl -v 'https://xxx-8000.use.devtunnels.ms/events?uid=3f13f220-54b8-4f63-acb5-cd5503ee4a67'
*   Trying x.x.x.x:443...
* Connected to xxx-8000.use.devtunnels.ms (x.x.x.x) port 443 (#0)
* ALPN: offers h2
* ALPN: offers http/1.1
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* (304) (OUT), TLS handshake, Client hello (1):
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-AES256-GCM-SHA384
* ALPN: server accepted h2
* Server certificate:
*  subject: C=US; ST=WA; L=Redmond; O=Microsoft Corporation; CN=devtunnels.ms
*  start date: Feb 10 00:22:09 2025 GMT
*  expire date: Aug  9 00:22:09 2025 GMT
*  subjectAltName: host "xxx-8000.use.devtunnels.ms" matched cert's "*.use.devtunnels.ms"
*  issuer: C=US; O=Microsoft Corporation; CN=Microsoft Azure RSA TLS Issuing CA 07
*  SSL certificate verify ok.
* Using HTTP2, server supports multiplexing
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* h2h3 [:method: GET]
* h2h3 [:path: /events?uid=3f13f220-54b8-4f63-acb5-cd5503ee4a67]
* h2h3 [:scheme: https]
* h2h3 [:authority: xxx-8000.use.devtunnels.ms]
* h2h3 [user-agent: curl/7.86.0]
* h2h3 [accept: */*]
* Using Stream ID: 1 (easy handle 0x7fc860011400)
> GET /events?uid=3f13f220-54b8-4f63-acb5-cd5503ee4a67 HTTP/2
> Host: xxx-8000.use.devtunnels.ms
> user-agent: curl/7.86.0
> accept: */*
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
< HTTP/2 504
< date: Fri, 07 Mar 2025 13:24:48 GMT
< content-type: text/html
< content-length: 160
< strict-transport-security: max-age=31536000; includeSubDomains
< x-served-by: tunnels-prod-rel-use-v3-cluster
<
<html>
<head><title>504 Gateway Time-out</title></head>
<body>
<center><h1>504 Gateway Time-out</h1></center>
<hr><center>nginx</center>
</body>
</html>
* Connection #0 to host xxx-8000.use.devtunnels.ms left intact

Expected output: Get the 200 OK response headers:

curl -v 'http://localhost:8000/events?uid=3f13f220-54b8-4f63-acb5-cd5503ee4a67'
*   Trying 127.0.0.1:8000...
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET /events?uid=3f13f220-54b8-4f63-acb5-cd5503ee4a67 HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.86.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< date: Fri, 07 Mar 2025 13:08:29 GMT
< server: uvicorn
< content-type: text/event-stream; charset=utf-8
< transfer-encoding: chunked
<

Additional notes:

  • for both curl requests, my local app's logs say the SSE requests are 200 OK
INFO   ::1:49463 - "GET /events?uid=3f13f220-54b8-4f63-acb5-cd5503ee4a67 HTTP/1.1" 200
INFO   127.0.0.1:50253 - "GET /events?uid=3f13f220-54b8-4f63-acb5-cd5503ee4a67 HTTP/1.1" 200
  • I also notice the sse request/response does not show up in the inspection UI (at https://...inspect.use.devtunnels.ms) see below: Image

bjsmiley avatar Mar 07 '25 13:03 bjsmiley

Thanks for filing the ticket. The underlying issue appears to be Support HTTP/2 on devtunnels.ms #263. This comment provides a workaround if that'd work for your scenario - https://github.com/microsoft/dev-tunnels/issues/263#issuecomment-1608243688.

derekbekoe avatar Mar 07 '25 17:03 derekbekoe

Thanks @derekbekoe, unfortunately it does not. I'm trying to expose a POC to a non technical group of people. No worries though as there are alternative services.

bjsmiley avatar Mar 10 '25 13:03 bjsmiley