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

P-Registrar-Error: Invalid CSeq number / NFON #1038

Open
benspi opened this issue Dec 15, 2023 · 1 comment
Open

P-Registrar-Error: Invalid CSeq number / NFON #1038

benspi opened this issue Dec 15, 2023 · 1 comment
Labels

Comments

@benspi
Copy link

benspi commented Dec 15, 2023

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:KC1KL4V5@KC1.reg.cloud-cfg.com
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:KC1KL4V5@KC1.reg.cloud-cfg.com;tag=d570-0cefe4cea546e72f9b2f9b00577b6839
From: sip:KC1KL4V5@KC1.reg.cloud-cfg.com;tag=NZWOIGANSL
Call-ID: fdf6f1f3595a4b8d88fe1502ec4e133a
CSeq: 2 REGISTER
Contact: sip:KC1KL4V5@192.168.0.10: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:KC1KL4V5@KC1.reg.cloud-cfg.com"),
        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();``
@sipsorcery
Copy link
Member

sipsorcery commented Jan 7, 2024

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.

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

No branches or pull requests

2 participants