Results 1 to 2 of 2

Thread: HTTP module and Timeouts

  1. #1
    Junior Member
    Join Date
    Dec 2023
    Posts
    25
    Rep Power
    4

    HTTP module and Timeouts

    This question is actually about the HTTP module, not INet. Anyhow...

    How reliable is the HTTP timeout system in the command "cHTTP_Client.SetTimeouts"? I think I have it properly set up in my script, but there's times when the script just hangs forever after a "<cHTTP_Client>.Send(requestBody)" statement. If the server doesn't reply after the specified amount of seconds, does it just keep retrying or is it supposed to return an error code, end the script, or what?

    Just to be clear. My script works fine when the server responds. It just sits forever at the .Send statement if the server is not responding. Here's a code fragment showing what I am doing...


    ' Create fresh HTTP request object for each attempt
        httpRequest = New ServerXMLHTTPRequest
    
    ' Set timeouts to prevent hanging (all in milliseconds)
    ' Parameters: resolveTimeout, connectTimeout, sendTimeout, receiveTimeout
        httpRequest.setTimeouts(15000, 20000, 30000, 30000)  ' 15, 20, 30, 30 seconds
    
        Printl "Setting up request with timeouts..."
    
    ' Make polling request
        Printl "httpRequest.Open( GET , pollUrl$, %FALSE)"
        httpRequest.Open("GET", pollUrl$, %FALSE)
    
        printl "httpRequest.Send() with timeout protection..."
        httpRequest.Send()
    
        apiResponse$ = httpRequest.ResponseText
        Printl "Response received, length: " & Str$(Len(apiResponse$))
        file_Save("hf_api_reply_step2_" & Str$(fileCounter) & ".txt", apiResponse$)
    

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    58
    Posts
    8,876
    Rep Power
    10
    This is a working example to use for testing:
    USES "MSXML2"
    uses "console"
    
    
      '---Define a new ServerXMLHTTPRequest object to be used to retrieve data from the web
      Dim oHTTP As new ServerXMLHTTPRequest
    
    
      '---Set time outs
      oHTTP.SetTimeOuts(15000, 1000, 1000, 1000)
    
    
      '------------------------------------------------------------
      ' SOME FAKE API end points
      '------------------------------------------------------------
      printl "---Fake API call---" in %CColor_fYellow
      
        'oHTTP.Open("GET", "https://dummyjson.com/carts", %FALSE)
        'oHTTP.Open("GET", "https://dummyjson.com/products", %FALSE)
        oHTTP.Open("GET", "https://fakerapi.it/api/v2/texts?_quantity=50&_characters=500", %FALSE)
      
      oHTTP.Send
      PrintL "Status:", oHTTP.Status, "(" & oHTTP.Statustext & ")"
    
    
      printl "---Press a key to show data---" in %CCOLOR_BLIGHTCYAN
      WaitKey
      
      PrintL oHTTP.ResponseText
    
    
      printl "---Press a key to end---"  in %CCOLOR_BLIGHTCYAN
      WaitKey
    
    The above code is working fine so we cannot test timeouts

    If you can give me an API not responding I can check timeouts
    Last edited by ErosOlmi; 17-09-2025 at 18:36.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

Similar Threads

  1. thinBasic on http://alternativeto.net/
    By ErosOlmi in forum thinBasic where ...
    Replies: 2
    Last Post: 31-12-2019, 11:19
  2. http://basic.mindteq.com/
    By ErosOlmi in forum Development
    Replies: 3
    Last Post: 13-03-2012, 04:40
  3. http://www.kickstarter.com/
    By ErosOlmi in forum General
    Replies: 0
    Last Post: 12-02-2012, 13:52
  4. http://bitnami.org/
    By ErosOlmi in forum Software discussion
    Replies: 1
    Last Post: 08-03-2010, 02:19
  5. http://www.codingmonkeys.com/
    By ErosOlmi in forum Announcements
    Replies: 0
    Last Post: 14-10-2006, 23:24

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •