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

Only receiving first chunk of data using FileMiddleware server #2871

Closed
GP89 opened this issue Aug 13, 2022 · 5 comments
Closed

Only receiving first chunk of data using FileMiddleware server #2871

GP89 opened this issue Aug 13, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@GP89
Copy link

GP89 commented Aug 13, 2022

Describe the bug

Only receiving first chunk of data receiving from FileMiddleware static server.

This could well be due to the way I'm using Network.framework as a test client, but I'm really not sure where the problem lies.

To Reproduce

I created a test project that demonstates the behaviour: TestStaticServer

Steps to reproduce the behavior:

  1. Run TestStaticServer target
  2. Run Downloader target
  3. Client only receives (for me) first chunk of data (174bytes) then no more

Expected behavior

Receive should keep receiving data until the whole file is sent (~3kb)

Environment

  • Vapor Framework version: main branch
  • Vapor Toolbox version: ?
  • OS version: 12.3.1
@GP89 GP89 added the bug Something isn't working label Aug 13, 2022
@GP89
Copy link
Author

GP89 commented Aug 14, 2022

Hey so I make a stupid mistake in that example! I was using strlen to get the message size, which is only the size until the first null byte 🤦 . So can confirm all the data is being received.
However the client is still sitting on receive expecting more data as is_complete doesn't come back as true. I'm not sure where / what the problem could be there

@vzsg
Copy link
Member

vzsg commented Aug 14, 2022

According to the Network.framework docs, if you're doing raw, unbounded TCP, is_complete will only be true if the other side closes the connection. In HTTP 1.1, connections are persistent by default, meaning that the server will not close the connection at the end of the response.

You could change the request line to say HTTP/1.0, or add a Connection: close header to the request, and it should be closed automatically by the server. (Or you could just use a real HTTP client instead?)

@GP89
Copy link
Author

GP89 commented Aug 14, 2022

Ah thank you!! Sorry I'll close this off.

I needed something that used tls psk and plain tcp was the only way I could find in objective-c.

@GP89 GP89 closed this as completed Aug 14, 2022
@GP89
Copy link
Author

GP89 commented Aug 14, 2022

Hey I've just tried with HTTP/1.0 and with Connection: close but I'm still seeing the same behaviour. Gets all the data and sits on state 3 (ready) waiting to receive again

@GP89 GP89 reopened this Aug 14, 2022
@0xTim
Copy link
Member

0xTim commented Aug 15, 2022

Do you get the same behaviour when serving the file from something like Nginx?

@GP89 GP89 closed this as completed May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants