Add HTTPTimeout
Add HTTPTimeout
It seems as AbortHTTP is working only when the download already began and is in progress, but not working while the connection is in progress? I have a server that exists but does not respond within 30 seconds, when I send an AbortHTTP after 5 secs, nothing happens (I expect to receive a #PB_HTTP_Aborted, which never arrives...)
As you walk on by, Will you call my name? Or will you walk away?
Re: AbortHTTP not working while connecting
Maybe this is only visible inside the purebasic source, so @Fred could you please verify this?
As you walk on by, Will you call my name? Or will you walk away?
Re: AbortHTTP not working while connecting
I think the main problem is that no (user definable) timeout is implemented.
Since the http is not in progress ...
you can not 'abort' the connection state.
Since the http is not in progress ...
you can not 'abort' the connection state.
Re: AbortHTTP not working while connecting
Moved to bug report for investigation
Re: AbortHTTP not working while connecting
Thanks for investigating, Fred.
As a workaround in the meantime, is it safe to implement a "hard" break like in the following code, or does this lead to internal memory leaks?
As a workaround in the meantime, is it safe to implement a "hard" break like in the following code, or does this lead to internal memory leaks?
Code: Select all
TickTimeout.q = ElapsedMilliseconds() + 1000 ; Timeout after 1sec
Request = HTTPRequest(#PB_HTTP_Post, "https://xxxxxxxxx/xxx/xxxService_v1", "Post Data here", #PB_HTTP_Asynchronous | #PB_HTTP_NoSSLCheck)
If Request
Debug "STARTED"
Repeat
Progress = HTTPProgress(Request)
Select Progress
Case #PB_HTTP_Success
Debug "SUCCESS"
Response$ = HTTPInfo(Request, #PB_HTTP_Response)
FinishHTTP(Request)
Break
Case #PB_HTTP_Failed
FinishHTTP(Request)
Response$ = "FAILED"
Debug "FAILED"
Break
Case #PB_HTTP_Aborted
FinishHTTP(Request)
Response$ = "ABORTED"
Debug "ABORTED"
Break
Default
Debug "PROGRESS = " + Progress
EndSelect
If ElapsedMilliseconds() > TickTimeout
Debug "ABOUT TO ABORT"
;--- HARD ABORT WHILE CONNECTING ---
If Progress = 0
FinishHTTP(Request)
Debug "HARD ABORT WHILE CONNECTING"
Break
EndIf
AbortHTTP(Request)
EndIf
Delay(250)
ForEver
EndIf
As you walk on by, Will you call my name? Or will you walk away?
Re: AbortHTTP not working while connecting
Do you mean it never returned anything ?
Re: AbortHTTP not working while connecting
I would like to cancel the async request after a specific timeout, so after my period of waiting time I manually call AbortHTTP(). This gives the internal HTTP functions the possibility to end and cleanup, I would then expect to receive a #PB_HTTP_Abort status afterwards which lets me quit my loop. This works fine while downloading a file is in progress, but while connecting, this does not work, I do never receive an abort status.Fred wrote:Do you mean it never returned anything ?
As you walk on by, Will you call my name? Or will you walk away?
Re: AbortHTTP not working while connecting
I will add an HTTPTimeout() function to allow to specify one, as clearing the request as you did can lead to crash when the internal libcurl timeout is reached.
Re: AbortHTTP not working while connecting
That would be perfect!Fred wrote:I will add an HTTPTimeout() function to allow to specify one, as clearing the request as you did can lead to crash when the internal libcurl timeout is reached.
As you walk on by, Will you call my name? Or will you walk away?
Re: AbortHTTP not working while connecting
Too bad this feature did not make it into the release. Hopefully another beta will come soon.Fred wrote:I will add an HTTPTimeout() function to allow to specify one, as clearing the request as you did can lead to crash when the internal libcurl timeout is reached.
As you walk on by, Will you call my name? Or will you walk away?
Re: Add HTTPTimeout
Yes, we need to freeze the dev at one point or it will never have any release
Re: Add HTTPTimeout
Fred wrote:Yes, we need to freeze the dev at one point or it will never have any release
Always in Beta, just like Microsoft Windows. Just call it "evergreen"