Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SIP registration using Ozeki SDK not working

Tags:

c#

voip

sip

nat

ozeki

i'm trying to build a simple VoIP application using c# so i found that the Ozeki SDK is the simple way to do that but when i'm trying to registration SIP account using the SIPAccount class from the Ozeki SDK and my local IP it fail always and this is the code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ozeki.VoIP;
using Ozeki.VoIP.SDK;

namespace SIP_R
{
    class Program
    {
        private static ISoftPhone softphone;   // softphone object
        private static IPhoneLine phoneLine;   // phoneline object

        private static void Main(string[] args)
        {
            // Create a softphone object with RTP port range 5000-10000
            softphone = SoftPhoneFactory.CreateSoftPhone(5000, 10000);

            // SIP account registration data, (supplied by your VoIP service provider)
            var registrationRequired = true;
            var userName = "1000";
            var displayName = "1000";
            var authenticationId = "1000";
            var registerPassword = "1000";
            var domainHost = SoftPhoneFactory.GetLocalIP().ToString();
            var domainPort = 9000;

            var account = new SIPAccount(registrationRequired, displayName, userName, authenticationId, registerPassword, domainHost, domainPort);

            // Send SIP regitration request
            RegisterAccount(account);

            // Prevents the termination of the application
            Console.ReadLine();
        }

        static void RegisterAccount(SIPAccount account)
        {
            try
            {
                phoneLine = softphone.CreatePhoneLine(account);
                phoneLine.RegistrationStateChanged += sipAccount_RegStateChanged;
                softphone.RegisterPhoneLine(phoneLine);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error during SIP registration: " + ex);
            }
        }

        static void sipAccount_RegStateChanged(object sender, RegistrationStateChangedArgs e)
        {
            if (e.State == RegState.Error || e.State == RegState.NotRegistered)
                Console.WriteLine("Registration failed!");

            if (e.State == RegState.RegistrationSucceeded)
                Console.WriteLine("Registration succeeded - Online!");
        }
    }
}

so please any help on what to do many thanks in advance for any help..

when trying to make softphone calls using Ozeki SDK and local IP it give an error NatType:UDPBlocked

like image 216
Fadi Avatar asked Apr 04 '15 04:04

Fadi


1 Answers

Do you have both UDP and TCP port 5060 open? (The standard SIP Port) Can you register a normal SIP softphone from your development machine?

From your error message it sounds like you have a firewall issue, not a code issue.

And looking at your code, I would check all the ports you've entered: 5,000 through 10,000.

like image 120
Shahzad Qureshi Avatar answered Oct 26 '22 07:10

Shahzad Qureshi