Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server recv a unrecgnized method may blocked all incoming request. #12

Closed
yushimeng opened this issue Mar 3, 2023 · 1 comment
Closed

Comments

@yushimeng
Copy link

If recv a register request, but server did not found handler by method, this tx will be blocked, and server routinue blocked.

The next response will not be reponsed.

`func (srv *Server) handleRequest(req *sip.Request, tx sip.ServerTransaction) {
for _, mid := range srv.requestMiddlewares {
mid(req)
}

handler := srv.getHandler(req.Method)

if handler == nil {
	srv.log.Warn().Msg("SIP request handler not found")
	res := sip.NewResponseFromRequest(req, 405, "Method Not Allowed", nil)
	if err := srv.WriteResponse(res); err != nil {
		srv.log.Error().Msgf("respond '405 Method Not Allowed' failed: %s", err)
	}
            //. no timer trigger. or we shoud destroy this tx.
	for {
		select {
		case <-tx.Done():
			srv.log.Warn().Msgf("recv tx.Done() tx:%s", tx)
			return
		case err, ok := <-tx.Errors():
			srv.log.Warn().Msgf("recv tx.Errors() tx:%s, err:%s", tx, err)
			if !ok {
				return
			}
			srv.log.Warn().Msgf("error from SIP server transaction %s: %s", tx, err)
		}
	}
}

handler(req, tx)
if tx != nil {
	// Must be called to prevent any transaction leaks
	tx.Terminate()
}

}`

@emiago
Copy link
Owner

emiago commented Mar 4, 2023

Hi @yushimeng
Thanks for reporting. This code was some leftover but never looked too much.
Anyway added a fix. We will terminate transaction. Also I am thinking this to be exported but for now leaving internally.
Check commit
a3cde53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants