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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With