Skip to content

[REQ][Qt5] Optional TimeOut #3064

@luStopai

Description

@luStopai

Is your feature request related to a problem?

Yes

Please describe.

I think Qt5 doesn't manage timeout problems by default. This means that if there is a timeout because of a firewall or an unresponsive server, the connection won't die since there is no mechanism to solve this situation.

Describe the solution you'd like

The usual solution is to set a Qtimer with setsingleshot=true and a timeout, then connect this qtimer timeout() signal to the QNetworkReply abort() slot. If the response happens before the timeout, then the timer has to be stopped. I think you can do this by connecting the finished signal of QNetworkReply to stop slot of the timer, or by calling stop manually when processing the response.

I thought of maybe making the constructor of the generated client depend on an optional timeout with a default value, for example MyConstructor(int timeout = 30). Another option is to set the optional timeout before making a request by using a simple setter.

I've also read about a complementary solution for a similar problem that consists in to combine the use of a qtimer with downloadProgress to check if a download has stopped or is slower than a threshold then abort the connection.

Describe alternatives you've considered

None comes to my mind

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions