Very slow request or connectTimeoutError - RequestsLibrary Robotframework

I automation API but it very slow , sometimes connectTimeoutError. Please help me

Hi @toaiphan,

If it’s simply your AUT taking time to respond, you can increase the timeout:

  • Create Session has a timeout option where you can set the timeout, so you can increase it from the default value.
  • POST’s **kwargs also has a timeout option (documented in GET) that you can use to set the timeout for specific requests.

But the question is why is the AUT taking so much time to respond?

  • Is it something in the way your test is setup
  • is it a fault with the AUT? can you reproduce this behaviour manually, if so, it’s a defect nothing to change in your test.

Somethings I did notice that you may need to pay attention to:

  • you create a session, but then don’t use it? POST On Session might be a better option than POST, also you might want to create the session in a Suite setup so you can reuse the session for all your tests
  • Your Authorisation=Bearer is hard coded:
    • does this expire after a few minutes? is the timeout’s you’re experiencing because the of a timed out Authorisation?
    • is there a limit to the number of sessions/connections that can use the same Bearer value? the first two tests used up the limit and the 3rd++ tests are timing out as the server is forcing them to wait for the first 2 sessions to expire? (if so, go back to my comment about creating the session in a Suite setup)

Hopefully something here will help you solve your issue,