diff --git a/pkg/sip/inbound.go b/pkg/sip/inbound.go index 2b34d6e..c6fb86c 100644 --- a/pkg/sip/inbound.go +++ b/pkg/sip/inbound.go @@ -1080,7 +1080,10 @@ func (c *sipInbound) transferCall(ctx context.Context, transferTo string) error return psrpc.NewErrorf(psrpc.InvalidArgument, "no From URI in invite") } - req := NewReferRequest(c.invite, c.inviteOk, transferTo) + // This will effectively redirect future SIP requests to this server instance (if host address is not LB). + contactHeader := &sip.ContactHeader{Address: sip.Uri{Host: c.s.signalingIp, Port: c.s.conf.SIPPort}} + + req := NewReferRequest(c.invite, c.inviteOk, contactHeader, transferTo) c.setCSeq(req) c.swapSrcDst(req) diff --git a/pkg/sip/outbound.go b/pkg/sip/outbound.go index c2cb95f..7c85806 100644 --- a/pkg/sip/outbound.go +++ b/pkg/sip/outbound.go @@ -694,7 +694,7 @@ func (c *sipOutbound) transferCall(ctx context.Context, transferTo string) error return psrpc.NewErrorf(psrpc.FailedPrecondition, "can't transfer hung up call") } - req := NewReferRequest(c.invite, c.inviteOk, transferTo) + req := NewReferRequest(c.invite, c.inviteOk, &sip.ContactHeader{Address: c.from.Address}, transferTo) c.setCSeq(req) cseq, _ := req.CSeq() diff --git a/pkg/sip/protocol.go b/pkg/sip/protocol.go index b7362a4..227f56f 100644 --- a/pkg/sip/protocol.go +++ b/pkg/sip/protocol.go @@ -75,7 +75,7 @@ func sendAndACK(c Signaling, req *sip.Request) { } } -func NewReferRequest(inviteRequest *sip.Request, inviteResponse *sip.Response, referToUrl string) *sip.Request { +func NewReferRequest(inviteRequest *sip.Request, inviteResponse *sip.Response, contactHeader *sip.ContactHeader, referToUrl string) *sip.Request { req := sip.NewRequest(sip.REFER, inviteRequest.Recipient) req.SipVersion = inviteRequest.SipVersion @@ -120,6 +120,8 @@ func NewReferRequest(inviteRequest *sip.Request, inviteResponse *sip.Response, r sip.CopyHeaders("CSeq", inviteRequest, req) } + req.AppendHeader(contactHeader) + cseq, _ := req.CSeq() cseq.SeqNo = cseq.SeqNo + 1 cseq.MethodName = sip.REFER