sipsorcery
sipsorcery copied to clipboard
P-Registrar-Error: Invalid CSeq number / NFON
Hello, I ran into an issue that i cannot re-register to our cloud pbx. are there any suggestions to overcome this issue?
Registering... Outbound proxy address: udp:109.68.97.120:5060. Sucessfully Registered to PBX!
After a while....:
Temporary error registering! Registration failed with BadRequest. sip:[email protected] BadRequest SIP/2.0 400 Bad Request Via: SIP/2.0/UDP 192.168.0.10:5061;received=86.XXXX.197;branch=z9hG4bKe6e074e37c1343a685e8431f299e2853;rport=61808 To: sip:[email protected];tag=d570-0cefe4cea546e72f9b2f9b00577b6839 From: sip:[email protected];tag=NZWOIGANSL Call-ID: fdf6f1f3595a4b8d88fe1502ec4e133a CSeq: 2 REGISTER Contact: sip:[email protected]:5061;expires=5;received="sip:86.XXXX:61808" Server: nfon2.0 Content-Length: 0 P-Registrar-Error: Invalid CSeq number
The Code:
static async Task Main(string[] args)
{
//INIT Console and other Basics
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Registering...");
var sipTransport = new SIPTransport(false);
sipTransport.EnableTraceLogs();
sipTransport.DisableRetransmitSending = true; //DEBUG
var udpChanel = new SIPUDPChannel(new IPEndPoint(IPAddress.Any, 5061));
sipTransport.AddSIPChannel(udpChanel);
//Register to PBX
var proxy = await SIPDns.ResolveAsync(SIPURI.ParseSIPURI("sip:KC1.reg.cloud-cfg.com;transport=udp"), false, CancellationToken.None);
Console.WriteLine($"Outbound proxy address: {proxy}.");
var contactUri = new SIPURI("KC1KL4V5", $"{ IPAddress.Any}:0", null, SIPSchemesEnum.sip, SIPProtocolsEnum.udp);
var regUserAgent = new SIPRegistrationUserAgent(sipTransport,
proxy,
SIPURI.ParseSIPURI("sip:[email protected]"),
USERNAME,
PASSWORD,
"KC1.reg.cloud-cfg.com",
"KC1.reg.cloud-cfg.com",
contactUri,
900,
null);
//var regUserAgent = new SIPRegistrationUserAgent(sipTransport, USERNAME, PASSWORD, SERVER, EXPIRY);
regUserAgent.RegistrationFailed += RegUserAgent_RegistrationFailed;
regUserAgent.RegistrationTemporaryFailure += RegUserAgent_RegistrationTemporaryFailure;
regUserAgent.RegistrationSuccessful += RegUserAgent_RegistrationSuccessful;
regUserAgent.RegistrationRemoved += RegUserAgent_RegistrationRemoved;
regUserAgent.UserAgent = "Sip2Mail";
regUserAgent.Start();``
Do you have the log messages from the sipsorcery attempts?
Also, this isn't correct $"{IPAddress.Any}:0"
. The contact URI needs a port. Either leave the 0 off to use the default 5060/5061 port or specify a dedicated port. If you have a NAT on your network path you can also leave off the 0 and the SIP registrar server should be able to deal with it.