OnCancel callback are not getting called. #107
Answered
by
pavanputhra
pavanputhra
asked this question in
Q&A
-
I have created simple snipped as follows. I am using a SIP soft phone to initiate call. I see I am not sure what I am doing wrong here. Please help. func main() {
addr := flag.String("l", "127.0.0.1:5060", "My listen ip")
flag.Parse()
setUpLogger()
log.Info().Msg("Starting SIP server")
// Setup UAC
ua, _ := sipgo.NewUA(
)
log.Info().Msg("User agent setup")
server, _ := sipgo.NewServer(ua)
server.OnCancel(func(req *sip.Request, tx sip.ServerTransaction) {
log.Info().Msg("CANCEL received")
})
server.OnInvite(func(req *sip.Request, tx sip.ServerTransaction) {
log.Info().Msg("INVITE received")
tx.Respond(sip.NewResponseFromRequest(req, sip.StatusTrying, "Trying", nil))
})
ctx, cancelFunc := context.WithCancel(context.Background())
go server.ListenAndServe(ctx, "udp", *addr)
log.Info().Msg("Server started at " + *addr)
sig := make(chan os.Signal)
signal.Notify(sig, os.Interrupt)
select {
case <-sig:
cancelFunc()
return
}
} Here is tcp dump if needed.
|
Beta Was this translation helpful? Give feedback.
Answered by
pavanputhra
Jul 23, 2024
Replies: 1 comment 1 reply
-
if cancel is termination of INVITE transcaction then this will be passed on transaction. Check go doc for ServerTransaction |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, CANCEL belongs to the same INVITE.
After experimenting, I found the following:
By modifying the OnInvite handler as shown below and adding a select with the case <-tx.Cancels(), I receive the CANCEL message via the tx.Cancels() channel, but not through the OnCancel callback. I believe this is the intended behavior.