Sessions and recovery

Most of a registrar client is straightforward. There is one hard part: what to do when no answer to a command ever arrives. This page is that part.

The question every write must be able to answer

The connection died after I sent the command. Did it happen?

Registering one name twice is not possible — the registry does not allow it, and the next section says how. The real danger is different: a client that does not know whether a command took effect will tell its customer something untrue — either that the name is theirs when it is not, or that the registration failed when it succeeded. Everything below exists to make that question always answerable.

Never blindly resend a write

A command that changes something — create, update, delete, renew, transfer, restore — is not safe to repeat just because you did not see its answer. Reconnect, find out what happened, then act.

The registry is built so that a resend cannot quietly double-apply:

  • create on a name that now exists answers 2302, including when the thing that created it was your own first attempt;
  • a name whose create is still pending is held under your account, so it is not available to anyone else while you work out what happened;
  • one operation per object runs at a time.

So a blind resend does not usually cost money. What it costs is certainty: you get a 2302 and cannot tell whether it means you already did this or somebody else got there first — and those need opposite responses.

How to find out what happened

1. <info> the object. This settles almost everything. The object exists with your clID as sponsor: your command worked. It does not exist: it did not. It exists with someone registrar as sponsor: you lost the race, and there is nothing to retry.

2. Read the message queue. If the answer you missed was 1001, the outcome is there and only there. Drain the queue before you conclude anything from <info> alone — the two together are the complete picture.

3. Then, and only then, act. Retry what demonstrably did not happen. Record what did.

Make clTRID unique for every command

Not per domain, not per session — per command, including retries. Store it with the operation in your own system before you send the frame.

<clTRID>EXAMPLE-19700101-000419</clTRID>

Two reasons, and the second is the one people discover late:

  • it is how you match an answer to the request that caused it, when both are lines in a log written days apart;
  • it is what we can search for when you ask about a specific operation. An svTRID is better still — it is ours and it identifies the command in our own records — so keep the svTRID from every answer, including from failures.

A support question that quotes one of those is answered in minutes. One that says "a create failed on Tuesday" has to be searched for by hand.

What each kind of reply means for your state machine

MeaningWhat your client does
1000donerecord it, charge your customer
1001accepted, not finishedrecord it as pending; the outcome arrives by poll. Do not resend, do not report success
2xxxnothing happenednothing was changed and nothing was charged — safe to correct and retry
no replyunknownreconnect, info, drain poll, then decide

The fourth row is the one that is usually missing from a first implementation, and 1001 is the one usually filed either as a success or as an error.

How to renew a domain correctly

renew is the one command where the obvious reading of success is wrong: the fact is the date in the answer, not the number of years you asked for. The procedure is this.

  1. Take the current expiry date from <info>, not from your own database. The <curExpDate> element is mandatory, and the server compares it with its own record.
  2. Send the renew with that date and the term you want.
  3. Store the <exDate> from the answer as the new expiry. Do not compute old + period: in zones with a grace period, and after an automatic renewal, the date can come out differently.

That <curExpDate> check is what makes a resend safe. If the renewal already applied, the date you sent is no longer the current one, so a second identical command gets 2105 rather than a second year. A <curExpDate> mismatch is therefore not a reason to substitute another date and try again: read <info> first and see whether the domain has already been renewed.

Sessions end, and that is normal

  • Idle for 10 minutes — closed. A <hello> every few minutes prevents it.
  • 24 hours old — closed, however busy. A long-running client must expect to re-login daily.
  • <logout> — closed, after 1500.
  • Three concurrent sessions per registrar; a fourth login gets 2502.

None of these is an error. Treat a closed connection as routine: reconnect, log in, continue. The one thing that must not happen is a reconnect turning into a resend of a command you never got an answer to.

Before you go live

  • ☐A unique clTRID per command, stored before sending.
  • ☐Every svTRID kept, including those from failures.
  • ☐1001 handled as its own state, resolved from the message queue.
  • ☐No automatic resend of any write on timeout — reconnect, info, poll, then decide.
  • ☐The message queue drained on a schedule, not only when a human looks.
  • ☐Renewal expiry read from the answer, never computed.
  • ☐Frames read by length, not by one read() call.
  • ☐Reconnect with backoff, and no tight retry loop on 2501.
  • ☐Tested against the OT&E sandbox first.

On this page