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

[REQ][Qt5] Optional TimeOut #3064

Closed
luStopai opened this issue Jun 2, 2019 · 1 comment · Fixed by #3078
Closed

[REQ][Qt5] Optional TimeOut #3064

luStopai opened this issue Jun 2, 2019 · 1 comment · Fixed by #3078

Comments

@luStopai
Copy link

luStopai commented Jun 2, 2019

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

@etherealjoy
Copy link
Contributor

Good description of a possible solution.
Thanks.

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

Successfully merging a pull request may close this issue.

2 participants