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

What is the maximum amount of data for a single transfer? #99

Open
Lucas2525117 opened this issue Jan 8, 2021 · 7 comments
Open

What is the maximum amount of data for a single transfer? #99

Lucas2525117 opened this issue Jan 8, 2021 · 7 comments
Labels

Comments

@Lucas2525117
Copy link

Question:
During self-test,the Web transfers data to the application through the tufao library,But when the amount of transmitted data is 128KB, the application does not receive the data message through the signal "newMessage", so I want to ask:“What is the maximum amount of data for a single transfer?”

Thanks!

@vinipsmaker
Copy link
Owner

The project doesn't put an upper limit to amount of read data:

priv->buffer += priv->socket.readAll();

And this is actually a problem as it makes your application subject to DoS attacks. It'd be better if it did put a limit, but I'm no longer maintaining this project and will not write such changes.

But when the amount of transmitted data is 128KB, the application does not receive the data message through the signal "newMessage"

I'm guessing this is a different problem. Are you writing a response? When the end of current message is reached, it stops reading new requests entirely:

disconnect(&priv->socket, SIGNAL(readyRead()),
this, SLOT(onReadyRead()));

Only when you reply to current request through the HttpServerResponse class...

emit finished();

...the HttpServerRequest class will resume reading new messages:

tufao/src/httpserver.cpp

Lines 133 to 134 in 4d89b6c

connect(response, &HttpServerResponse::finished,
request, &HttpServerRequest::resume);

That's how I can ensure you'll not get data() signals to the wrong request when HTTP pipelining is at play.

@Lucas2525117
Copy link
Author

In fact, my application uses the "newMessage" signal to get the message sent to me from the web.
At the same time, one problem I want to talk about is that my application communicates with the front end through websocket.
Under the premise of websocket communication, some short messages can be received through the "newMessage" signal, but longer messages are transmitted. As mentioned in my question, the web transmits a 128KB message through websocket , But the application did not receive the newMessage signal.
tufao/src/websocket.cpp
if (priv->frame.fin()) { // FINAL if (priv->frame.isControlFrame()) { evaluateControlFrame(); } else { if (priv->frame.opcode() == FrameType::CONTINUATION) { // CONTINUATION QByteArray chunk(priv->fragment); priv->fragment.clear(); emit newMessage(chunk); } else { // NON-CONTINUATION QByteArray chunk(priv->payload); priv->payload.clear(); emit newMessage(chunk); } } }

@vinipsmaker
Copy link
Owner

Oh, I didn't realize you were talking about the WebSocket support. Sorry.

There is a bug in the payload parsing code for the WebSocket protocol.

@vinipsmaker vinipsmaker added the bug label Jan 8, 2021
@Lucas2525117
Copy link
Author

Can you elaborate more? What is the specific cause of the error?

Thanks!

@vinipsmaker
Copy link
Owner

Can you elaborate more? What is the specific cause of the error?

Unfortunately I wrote the code long ago and don't remember the details. Nor do I have time to maintain this project anymore, so you'll have to look by yourself (the file is src/websocket.cpp).

Although I don't have the time to maintain this project any longer, I still do remember the HTTP classes quite well. If the bug was related to HTTP, I could offer a little helping hand.

@harryhdk
Copy link

Can you elaborate more? What is the specific cause of the error?

Thanks!

Question:
During self-test,the Web transfers data to the application through the tufao library,But when the amount of transmitted data is 128KB, the application does not receive the data message through the signal "newMessage", so I want to ask:“What is the maximum amount of data for a single transfer?”

Thanks!

Have you solved the problem?

@vinipsmaker
Copy link
Owner

@Lucas2525117 can you test if the PR #101 fixes the issue for you? I'm gonna merge it soon.

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

No branches or pull requests

3 participants