vinipsmaker / tufao

An asynchronous web framework for C++ built on top of Qt

Home Page:http://vinipsmaker.github.io/tufao/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Lucas2525117 opened this issue · comments

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!

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.

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); } } }

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.

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

Thanks!

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.

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?

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