How to solve request timeout error in setup?

In the setup function, I m creating a seed which is response of createPickingStartedSalesOrdersRes .Normally,It works about 4m and returns a json list containing 1000 items. I’m pulling each item of this returned json list inside the Packing function. But I got an error on the setup side. First, I got the setup timeout error. Then I added the setupTimeout to the options the setup timeout error solved. But this time, the endpoint which I run for the seed falls on the timeout and response body returns null. The interesting thing is that when I type 500 instead of 1000 for the amount, it works 1 minute and everything works very well. It works fine without timeout for endpoint 500 which I use for Seed. Tried this seed on swagger environment before and supports 25000 amount.

When I used 1000 giving below error ;
error=“Post "https://tests/test/test”: request timeout"

How can I solve this issue? What am I doing wrong on the code side? The main issue here is that the seed must run before the Packing function and the list must return. I should be able to read that list .By the way read this but I didn’t find response for myself

export function setup() {

  let createPickingStartedSalesOrdersRes = http.post(
    Load.api + endpoints.SalesOrderLoadSeed.CreatePickingCompletedSalesOrders,
    JSON.stringify({
      salesOrderConfigurations: [
        {
          referenceNumberPrefix: "XL-",
          amount: 1000,
        },
      ],
      operation: "test",
    }),
    {
      headers: {
        apikey: "test",
        "Content-Type": "application/json",
      },
    }, {timeout: "4m"}

  );

  let operatorAuth = Load.auth(Roles.Operator);
  let supportAuth = Load.auth(Roles.Support);

  return [
    operatorAuth.json(),
    supportAuth.json(),
    createPickingStartedSalesOrdersRes.json(),
  ];

}

const totalVu = 20;
export const options = {

  setupTimeout: '4m',

  summaryTimeUnit: "ms",

  scenarios: {

    Packing: {

      exec: "Packing",

      executor: "per-vu-iterations",

      vus: totalVu,

      iterations: 50,

      maxDuration: '1h',

    },
  },
};

export function Packing(data) {

  let tokenForOperator = data[0].access_token;
  let tokenForSupport = data[1].access_token;

  describe("test", (t) => {
    Load.post(endpoints.PackingProcesses.createPackingProcessIfNotExists,
      tokenForOperator,
      JSON.stringify({
        pickingToteLabel: `${data[2][(totalVu * (exec.vu.iterationInInstance)) + (exec.vu.idInTest - 1)]}`
      })
    );

 });
  }

Hi @Yusuf!
setupTimeout: ‘4m’, this option sets the duration of the function export const options = {}.
Waiting for a response from the server cannot be changed and its value is 60s.

Hi @PaulM Thanks for reply but I didn’t understand properly.Could u give me more detail. I guess you meant that setup function’s default value is 60s and it will not change even if I use the setupTimeout in options . But I used Params.timeout in my endpoint taking error again.

let createPickingStartedSalesOrdersRes = http.post(
Load.api + endpoints.SalesOrderLoadSeed.CreatePickingCompletedSalesOrders,
JSON.stringify({
salesOrderConfigurations: [
{
referenceNumberPrefix: “XL-”,
amount: 1000,
},
],
operation: “test”,
}),
{
headers: {
apikey: “test”,
“Content-Type”: “application/json”,
},
}, {timeout: “4m”}

);

@Yusuf, when we try to get a response from the server the script k6 will fixedly wait 60 sec. This cannot be changed yet.
The setupTimeout function has a maximum wait time of 4 minutes.
Waiting for a function to complete is not the same as waiting for a response from the server.
@inanc @mstoykov correct me if i’m not right

@PaulM, you cannot the change the HTTP request timeout globally yet, but you can change it for an individual HTTP request, see timeout in Params

1 Like

@ned Thank you for your answer! Do I understand correctly that in any case the maximum for the timeout is 60 seconds?

Thanks for info @PaulM and @ned

@PaulM, there is no artificial upper or lower limit, you can have whatever timeout you want. Of course, you are limited by the remaining scenario duration (and gracefulStop), but that’s another matter.

1 Like