gpt4 book ai didi

c# - 使用 Ozeki SDK 的 SIP 注册不起作用

转载 作者:太空狗 更新时间:2023-10-29 17:56:06 25 4
gpt4 key购买 nike

我正在尝试使用 C# 构建一个简单的 VoIP 应用程序,所以我发现 Ozeki SDK 是实现此目的的简单方法,但是当我尝试使用 注册 SIP 帐户时Ozeki SDK 中的 >SIPAccount 类和我的本地 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!");
}
}
}

因此,请提前就如何操作提供任何帮助,非常感谢您提供任何帮助..

当尝试使用 Ozeki SDK 和本地 IP 进行软电话调用时,出现错误 NatType:UDPBlocked

最佳答案

您是否同时打开了 UDP 和 TCP 端口 5060? (标准 SIP 端口)你能从你的开发机器上注册一个普通的 SIP 软电话吗?

从您的错误消息来看,您似乎遇到了防火墙问题,而不是代码问题。

查看您的代码,我会检查您输入的所有端口:5,000 到 10,000。

关于c# - 使用 Ozeki SDK 的 SIP 注册不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29442878/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com