Fad*_*adi 10 c# voip sip nat ozeki
我正在尝试使用c#构建一个简单的VoIP应用程序,所以我发现这Ozeki SDK是一种简单的方法,但是当我尝试使用SIPAccount来自Ozeki SDK和我的本地的类注册SIP帐户时,IP它总是失败,这就是代码
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!");
}
}
}
Run Code Online (Sandbox Code Playgroud)
所以,请提前做任何帮助,以获得任何帮助.
当尝试使用Ozeki SDK和本地IP进行软电话呼叫时,会出错 NatType:UDPBlocked
您是否同时打开了 UDP 和 TCP 端口 5060?(标准 SIP 端口)您可以从您的开发计算机注册普通的 SIP 软电话吗?
从您的错误消息来看,您似乎遇到了防火墙问题,而不是代码问题。
查看您的代码,我会检查您输入的所有端口:5,000 到 10,000。
| 归档时间: |
|
| 查看次数: |
2652 次 |
| 最近记录: |