Summary:ASTERISK-23707: Realtime Contacts: Apparent mismatch between PGSQL database state and Asterisk state
Reporter:Mark Michelson (mmichelson)Labels:
Date Opened:2014-05-01 18:29:01Date Closed:2014-05-02 15:08:41
Versions:Frequency of
Description:I was investigating a reported issue that phones appeared as UNAVAILABLE instead of NOT_INUSE when they were idle. After experimenting a bit, I can semi-reliably make this happen.

I'm using realtime for my PJSIP contacts. The scenario is that the contacts database table has an entry for a contact that corresponds to a particular device. With this entry existing, Asterisk starts up. The device now attempts to REGISTER to Asterisk and things go poorly. Asterisk does not recognize that this inbound registration matches up with a contact that has already been registered by the device and as such treats the REGISTER as a new registration. When Asterisk tries to create a contact using sorcery, this fails since the database already has an entry with the given primary key.

The registrar responds with a 200 OK (I haven't checked to see if there are any Contact headers in the 200 OK), so the device thinks that has successfully registered.

If someone attempts to place a call to this device, Asterisk can successfully complete the call since there is a database entry for the contact.

When the device is in a call, its device state appears as INUSE. When the call finishes, the device becomes UNAVAILABLE since Asterisk thinks that it is not registered.
Comments:By: Matt Jordan (mjordan) 2014-05-01 21:26:17.043-0500

How are mapping an inbound REGISTER request to an existing contact? Wouldn't the same failure potentially occur on a re-REGISTER?