CallerID not working using SIPSorcery .net 6 with Voip.ms

When using SIPSorcery with .NET 6 to make SIP calls via VoIP.ms, the custom Caller ID is not being passed correctly, despite being set in the code.

We have the setting configured in VoIP.ms as:
“I use a system capable of passing its own CallerID”


using ConsoleApp.Sipsorcery;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Serilog;
using Serilog.Extensions.Logging;
using SIPSorcery.Media;
using SIPSorcery.SIP;
using SIPSorcery.SIP.App;

public class Program
{
    private static Microsoft.Extensions.Logging.ILogger _logger = NullLogger.Instance;

    const string destination = "DESTINATION_NUMBER";
    const string username = "USERNAME";
    const string password = @"PASSWORD";
    const string domain = "xxxxx.voip.ms";

    // Internal variable for Caller ID
    private static string callerId = "OWN_CALLER_ID"; 

    public static async Task Main(string[] args)
    {
        AddConsoleLogger();

        _logger.LogInformation("SIP Get Started");

        var userAgent = new SIPUserAgent();
        var voipMediaSession = new VoIPMediaSession();
        voipMediaSession.AcceptRtpFromAny = false;
        voipMediaSession.AudioExtrasSource.SetSource(AudioSourcesEnum.Silence);

        SipDialerAccount sipDialerAccount = new SipDialerAccount();
        int maxRetries = 5;
        int retryCount = 0;
        bool callResult = false;

        while (retryCount < maxRetries)
        {
            try
            {
                SIPCallDescriptor callDescriptor = new SIPCallDescriptor(
                    username: username,
                    password: password,
                    uri: $"sip:{destination}@{domain}",
                    from: $"sip:{callerId}@{domain}",
                    to: $"sip:{destination}@{domain}",
                    routeSet: null,
                    customHeaders: null,
                    authUsername: null,
                    callDirection: SIPCallDirection.Out,
                    contentType: null,
                    content: null,
                    mangleIPAddress: null);

                callResult = await userAgent.Call(callDescriptor, voipMediaSession, 0);

                if (callResult)
                {
                    _logger.LogInformation("Call succeeded.");
                    break;
                }
                else
                {
                    _logger.LogWarning($"Call failed. Retrying... (Attempt {retryCount + 1} of {maxRetries})");
                    retryCount++;
                    await Task.Delay(10000); // Delay between retries
                }

            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error making call.");
                break;
            }
        }

        if (!callResult)
        {
            _logger.LogError("All call attempts failed.");
        }
    }

    private static void AddConsoleLogger()
    {
        var logger = new LoggerConfiguration()
            .Enrich.FromLogContext()
            .MinimumLevel.Is(Serilog.Events.LogEventLevel.Debug)
            .WriteTo.Console()
            .CreateLogger();
        var factory = new SerilogLoggerFactory(logger);
        SIPSorcery.LogFactory.Set(factory);
        _logger = factory.CreateLogger<Program>();
    }
}

This is the Serilog output:

[22:51:12 INF] SIP Get Started [22:51:12 DBG] CreateRtpSocket attempting to create and bind RTP socket(s) on [::]:0. [22:51:12 DBG] CreateBoundSocket attempting to create and bind socket(s) on [::]:0 using protocol Udp. [22:51:12 DBG] CreateBoundSocket even port required, closing socket on [::]:49667 and retrying on 49668. [22:51:12 DBG] CreateBoundSocket attempting to create and bind socket(s) on [::]:49669 using protocol Udp. [22:51:12 DBG] CreateBoundSocket successfully bound on [::]:49669, dual mode True. [22:51:12 DBG] Successfully bound RTP socket [::]:49668 (dual mode True) and control socket [::]:49669 (dual mode True). [22:51:12 DBG] RTPChannel for [::]:49668 started. [22:51:12 DBG] SIPClientUserAgent attempting to resolve atlanta2.voip.ms. [22:51:13 DBG] SIPClientUserAgent resolved atlanta2.voip.ms to udp:MY_IP:5060 in 1074.87ms. [22:51:13 DBG] UAC commencing call to sip:[email protected]:5060. [22:51:14 DBG] CreateBoundSocket attempting to create and bind socket(s) on 0.0.0.0:0 using protocol Udp. [22:51:14 DBG] CreateBoundSocket successfully bound on 0.0.0.0:57590. [22:51:14 INF] SIP UDP Channel created for udp:0.0.0.0:57590. [22:51:14 DBG] Information response 100 Trying for sip:[email protected]. [22:51:14 INF] Call attempt to sip:[email protected] received a trying response INVITE 100 Trying. [22:51:14 DBG] Response 603 Declined for sip:[email protected]. [22:51:14 WRN] Call attempt was answered with failure response INVITE 603 Declined. [22:51:14 WRN] Call failed. Retrying… (Attempt 1 of 5)

Do I missing something for the callerId ???

New contributor

LeanTyl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật