[Gambas-user] HTTPClient freeze after 40 mins with Gambas 3.18.4
Christof Thalhofer
chrisml at deganius.de
Sat Sep 30 12:50:20 CEST 2023
Hello Fabien, hello Benoît,
Am 30.09.23 um 11:12 schrieb Fabien Bodard:
> Can you try to change your get function
>
> Like This :
>
> Public Function Get(sUrl as String) As String
>
> Dim sBuffer As String
>
> If sUrl Then
> $H = New HttpClient As "HClient"
> $H.Url = sUrl
> $H.Async = False
> $H.Timeout = 600
>
> $H.Get
>
> ' Success - read the data
> If Lof($H) Then sBuffer = Read #$H, Lof($H)
>
> If $H.Code 299 Then
> Error.Raise("Degapp Fehler – Code " & $H.Code & " " & sBuffer)
> Endif
>
> If $H.Status < 0 Then
> Error.Raise("Connection zu Degapp kaputt. Curl Status (" &
> $H.Status & ") kleiner 0.")
> Else
> $H.Close
> Return sBuffer
> End If
> Else
> Error.Raise("Der Pfad für Degapp ist nicht definiert.")
> Endif
>
> Wait
>
> End
>
>
> In This case any call to get generate a new HttpClient and a Wait call
Thank you! I had the same idea this morning and did a similar thing
(except the 'Wait', but now I tried it). Meanwhile I have an extra
branch of my software just to investigate this bug.
No change in behavior, it still leaks file descriptors ...
but now I tested further. With this the leak is gone!:
> 'For testing: Get with HttpClient defined in the scope of the function
> Public Function Get() As String
>
> Dim sBuffer, sUrl As String
> Dim H As HttpClient
>
> sUrl = "http://degapp/1/eingaenge?"
>
> If sUrl Then
> H = New HttpClient As "HClient"
>
> H.Auth = Net.AuthBasic
> H.User = LocalSettings.Username
> H.Password = LocalSettings.PW
>
> H.Url = sUrl
> H.Async = False
> H.Timeout = 600
>
> H.Get
>
> ' Success - read the data
> If Lof(H) Then sBuffer = Read #H, Lof(H)
>
> If H.Code = 299 Then
> Error.Raise("Degapp Fehler – Code " & H.Code & " " & sBuffer)
> Endif
>
> If H.Status < 0 Then
> Error.Raise("Connection zu Degapp kaputt. Curl Status (" & H.Status & ") kleiner 0.")
> Else
> H.Close
> Return sBuffer
> End If
> Else
> Error.Raise("Der Pfad für Degapp ist nicht definiert.")
> Endif
>
> End
Now the HttpClient object lives only inside the scope of the function.
Then it leaks no file desriptors any more!
If the HttpClient object exists in the scope of the class the bug occurs!
Alles Gute
Christof Thalhofer
--
Dies ist keine Signatur
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230930/8fe07589/attachment.sig>
More information about the User
mailing list