Welcome to Portkey Forum

Updated 8 months ago

@Team Portkey - i tried a config with

@Team Portkey - i tried a config with timeout of 30s and 3 retries. i doesn't look it does an automatic retry if the timeout happens. the retry is only triggered on failure. is this expected behaviour?
V
t
v
9 comments
Hey @thismlguy yes this is expected behaviour. If the config has request_timeout AND retry - you can create the Config to allow retry on specific error codes. This is how it would look:

Plain Text
{
  "retry": {
    "attempts": 3,
    "on_status_codes": [
      408
    ]
  }
}

408 is the status code for timeouts. You can read more here

Please let me know if this explains it! πŸ˜„
i dont want to restrict retry only on timeout.
or i guess there's no other case that you might catch actually
other retires are done in code based on whether the response is a correct json format. is there a way to set a json schema check for retry with portkey?
Hey @thismlguy - We currently do not support json schema based retries. But we are soon adding real-time evaluations where you can define simple rules in config like contains, doesNotContain, etc. We can add a rule for json schema matching as well in this. With the rules, you will also be able to add auto retry setting on evaluation rule failure. I hope this will help your use case. I will keep you on the list to try it out when we release its first version.
sure thanks. its not urgent for me as i do this using code anyways
and i might keep doing that as the logic might be more advanced than just checking for strings.
Portkey by default triggers retries on 5 status codes: [429, 500, 502, 503, 504]

And for status codes other than this, you'd have to manually add them in your retry config with the on_status_codes param.

So here what you could do is, write your retry config like this:
Plain Text
{
  "retry": {
    "attempts": 3,
    "on_status_codes": [
      408, 429, 500, 502, 503, 504
    ]
  }
}

And this will ensure that you are triggering retry on all status codes, including when you get timed out.

Let me quickly explain why we have only 5 default status codes for retry: Since Portkey config also has fallbacks/loadbalancing logic, in many scenarios when there's a failure other than the above 5 status codes, the expected behaviour is to move on to the next target rather than trying the previous target again, and hence if you want to still retry, we expect the user to manually set it.
got it, will try this
Add a reply
Sign up and join the conversation on Discord