Further investigation shows that the database loses b_contact when the called side sends the session timer reINVITE.
At beginning of the call:
``` *************************** 1. row *************************** id: 762 rectime: 2017-03-08 09:29:13 s_method: INVITE s_cseq: 2 a_callid: DaDWA2PfEHrzY2yHo-7UmQ.. a_uuid: atpsh-58bf061d-69c4-4 b_uuid: btpsh-58bf061d-69c4-4 a_contact: sip:xxxxxxxxx@10.50.50.50:32709;transport=UDP b_contact: sip:2500991234@10.20.0.224:5060 as_contact: sip:atpsh-58bf061d-69c4-4@10.10.0.180 bs_contact: sip:btpsh-58bf061d-69c4-4@10.10.0.180 a_tag: 976c020a b_tag: as22aeaf5f a_rr: b_rr: sip:10.10.0.177:5065;lr=on s_rr: sip:10.10.0.180;lr;ftag=976c020a;dv=aae.5ab1 iflags: 2 a_uri: b_uri: r_uri: a_srcaddr: b_srcaddr: a_socket: b_socket: ```
If the call is ended at this point, the BYE is sent correctly.
However, when the called side's session timer expires and it sends a reINVITE, the database changes to this:
``` *************************** 1. row *************************** id: 762 rectime: 2017-03-08 09:29:13 s_method: INVITE s_cseq: 2 a_callid: DaDWA2PfEHrzY2yHo-7UmQ.. a_uuid: atpsh-58bf061d-69c4-4 b_uuid: btpsh-58bf061d-69c4-4 a_contact: sip:xxxxxxxxx@10.50.50.50:32709;transport=UDP b_contact: <--- this is now blank as_contact: sip:atpsh-58bf061d-69c4-4@10.10.0.180 bs_contact: sip:btpsh-58bf061d-69c4-4@10.10.0.180 a_tag: 976c020a b_tag: as22aeaf5f a_rr: b_rr: sip:10.10.0.177:5065;lr=on s_rr: sip:10.10.0.180;lr;ftag=976c020a;dv=aae.5ab1 iflags: 2 a_uri: b_uri: r_uri: a_srcaddr: b_srcaddr: a_socket: b_socket: ```
If the call is ended by the caller after this, it sends `BYE sip:10.10.0.177:5065;lr=on SIP/2.0` instead of `BYE sip:2500991234@10.20.0.224:5060 SIP/2.0` as expected.