Retries and replays
If your server is down or slow, KnownVisitors keeps trying for about 8½ hours. After that you can send any failed delivery again from the app.
What counts as delivered
A delivery succeeds when your server answers with any 2xx status within 10 seconds. Everything else counts as a failure:
- a
4xxor5xxstatus - no answer within 10 seconds
- a redirect (
3xx). We do not follow redirects, so give us the final URL. - a connection or certificate error
Retry schedule
A failed delivery is tried again on this schedule, 6 tries in all:
| Try | When |
|---|---|
| 1 | Right away |
| 2 | About 1 minute after try 1 |
| 3 | About 5 minutes after try 2 |
| 4 | About 30 minutes after try 3 |
| 5 | About 2 hours after try 4 |
| 6 | About 6 hours after try 5 |
The X-KV-Delivery-Attempt header tells you which try a request is. After the 6th try fails, the delivery is marked as failed and we stop.
Replay a failed delivery
Open the address in the app and find the delivery in Recent deliveries. Fix the problem on your server, then click Replay to send it again.
Handle duplicates
You can receive the same event more than once, for example when your server saved an event but answered too late. Every try of an event carries the same id, also sent as the X-KV-Event-Id header.
- Record the IDs you have processedStore each event
idafter you save it. - Skip ones you have seenIf an
idarrives again, answer200and do nothing else.
Use person_id as the key for the person in your system. The same person always has the same ID, so a duplicate updates a record instead of creating a second one.
Order of events
Retries mean events can arrive out of order. Do not rely on the order requests arrive in. Use the created time on the event if you need to know which came first.
Answer quickly
Save the event and answer 200 first, then do slow work such as calling other services in the background. Slow handlers are the most common reason deliveries time out and get retried.