2011/4/13 Pan B. Christensen pan@ibidium.no:
Scenarios: A call comes in from Nortel/PSTN (user A) through Nortel1 to a SIP device (user B). User B pushes the transfer button (puts current call on hold and makes a new call) and dials a Nortel / PSTN number to user C. This call goes out through the nortel2 server. Users B and C talk a short while before user B pushes the Transfer button again to connect users A and C. In this scenario, the REFER is forwarded by kamailio to nortel1, which replies "SIP/2.0 481 Call leg/transaction does not exist." The call to join is of course on the other asterisk (nortel2).
The problem here is just in Nortel 1. It receives an in-dialog REFER through the dialog between user A and B, and such dialog contains a "replaces" parameter so user B can generate an INVITE with "Replaces" header to user C and the attended transfer completes.
But for this to work you should use a single Nortel instance rather than two or more (I assume that the Nortel behaves as a PBX). The REFER Nortel (User 1) receives indicates it to call to another PSTN number, so it would generate a new call to the PSTN (rather than routing such an INVITE to the other Nortel box).
It's not possible your scenario. It's certainly hard to balance traffic when you need a PBX role.
A similar scenario is where user B transfers to another SIP user. This call will only exist in one of the kamailio servers, and Asterisk will give the same response to the REFER.
A third scenario is where both calls are handled by the same Asterisk server. This scenario works.
I'm assuming I'll have to build REFER-handling logic into kamailio, but am unsure of how to proceed. Any suggestions?
No, Kamailio can do nothing here. REFER is just an in-dialog request Kamailio correctly routes in the loose_route section. The problem is not the proxy, the problem is the explained above.
Regards.