sipsorcery-org / sipsorcery

A WebRTC, SIP and VoIP library for C# and .NET. Designed for real-time communications apps.
https://sipsorcery-org.github.io/sipsorcery
Other
1.39k stars 424 forks source link

Incremented CSeq number with each REGISTER request #1098

Closed ynborokh closed 3 months ago

ynborokh commented 3 months ago

Currently, after receiving 401 Unauthorized response for an initial REGISTER request (with CSeq=1), we add the authorization info to the request (incrementing its CSeq to 2) and resend it. The problem is that the SIPRegistrationUserAgent instance is not aware that CSeq was incremented, and, so, when we call SIPRegistrationUserAgent.Stop() in order to remove the registration on the server side, the corresponding request with Expires=0 is sent with CSeq=2 and so is ignored by the server, since CSeq must be incremented with each subsequent request (or at least be unique).