Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble when Hummingbird 2.0.1 used with an Nginx proxy. #570

Open
dkyowell opened this issue Sep 29, 2024 Discussed in #568 · 3 comments
Open

Trouble when Hummingbird 2.0.1 used with an Nginx proxy. #570

dkyowell opened this issue Sep 29, 2024 Discussed in #568 · 3 comments

Comments

@dkyowell
Copy link

Discussed in #568

Originally posted by dkyowell September 28, 2024
I have been converting some internal projects from Vapor to Hummingbird. I have run into an issue when using Hummingbird as the protected server behind an Nginx reverse proxy. My Hummingbird based server generates PDF content dynamically. It works perfectly when accessed directly by clients on the LAN. It works across the Nginx proxy when the PDF is very small. When the PDF is larger, I get the following error in my iOS client using URLSession. (It also fails to load from Postman when used with the proxy). The exact same client setup and Nginx reverse proxy worked fine when using Vapor.

Task <8A55EAB5-D2A9-4D3C-A478-F107C107C304>.<29> failed strict content length check - expected: 283409, received: 131629, received (uncompressed): 0

Any thoughts on what could be causing this?

@Joannis
Copy link
Member

Joannis commented Sep 30, 2024

How do you create the ResponseBody containing the PDF? I think it's related to that

@dkyowell
Copy link
Author

let body = ResponseBody.init(byteBuffer: .init(data: pdfData))
var headers = HTTPFields.init()
headers.append(.init(name: .contentType, value: MediaType.applicationPdf.description))
return .init(status: .ok, headers: headers, body: body)

@adam-fowler
Copy link
Member

Hi @dkyowell sorry for the delayed reply. This is most likely due to the connection being closed immediately after the response write because the server received a connection: close header. There is a known issue in the swift-nio NIOAsyncChannel where it is not flushing writes before a close. Until this is fixed by swift-nio there isn't much we can do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants