-
Notifications
You must be signed in to change notification settings - Fork 498
Description
Hi, first of all thank you for your great work on this project!
I am trying to use this library to make an automated call to a SIP Trunk under certain conditions and I am having trouble with the telephone system at the customers site:
I have used MicroSIP to verify the registration and the call to the SIP Trunk both work. However, when I use my custom application, I get a "404 not found" response from the telephone system. I captured the invites from sipSorcery (first) and microsip (after the new registration).
(Sorry, I cant copy files or text from the machine I am working from..)
Here is an invite created with sipSorcery (response: 404 not found):
And here is an invite created by microSIP (working):
The difference that I can make out is:
-
The "Contact" field, at the MicroSIP invite its 5060@ip, where as with the bad invite its just the ip.
-
The Authorization field is missing in the sipsorcery invite.. But I would expect a different error if the request were not authorized.
I do not have a lot of experience with SIP, so maybe something else is wrong or there is an obvious mistake somewhere.
But I cant figure out how to match the differences that I mentioned above and I dont know if they even cause the issue I am having..
What i am currently doing in code are basically the following steps:
private const string SERVER_IP = "10.135.134.132";
private const int SERVER_EXPIRY = 500;
private const string PROXY_IP = "10.135.134.132";
private const int PROXY_PORT = 5060; // outbound proxy port
private const string TRUNK_DOMAIN = "testdomain.com"; // no leading '@'
private const string CALLER_USER = "5060";
private const string CALLER_PW = "SIPCalling";
static SIPTransport _sipTransport = new SIPTransport();
// Use default options to set up a SIP channel.
SIPUserAgent userAgent;
SIPRegistrationUserAgent regUserAgent;
WindowsAudioEndPoint winAudio = new SIPSorceryMedia.Windows.WindowsAudioEndPoint(new SIPSorcery.Media.AudioEncoder());
_sipTransport = new SIPTransport();
_sipTransport.AddSIPChannel(new SIPUDPChannel(new IPEndPoint(System.Net.IPAddress.Any, 0)));
_sipTransport.CustomiseRequestHeader = (local, remote, req) =>
{
if (req.Method == SIPMethodsEnum.INVITE)
{
req.Header.Contact = new List<SIPContactHeader> { SIPContactHeader.GetDefaultSIPContactHeader(SIPSchemesEnum.sip) };
}
return req.Header;
};
var outboundProxy = new SIPEndPoint(SIPProtocolsEnum.udp, System.Net.IPAddress.Parse(PROXY_IP), PROXY_PORT);
userAgent = new SIPUserAgent(_sipTransport, outboundProxy);
SIPURI AOR = new SIPURI("5060", TRUNK_DOMAIN, "");
SIPURI contact = new SIPURI("5060", "10.135.134.122", "");
regUserAgent = new SIPRegistrationUserAgent(_sipTransport, outboundProxy, AOR, CALLER_USER, CALLER_PW, "5060", TRUNK_DOMAIN, contact, SERVER_EXPIRY, [""]);
regUserAgent.RegistrationSuccessful += registerSuccessful;
regUserAgent.RegistrationFailed += registerFailed;
regUserAgent.RegistrationRemoved += registerRemoved;
regUserAgent.Start();
VoIPMediaSession voipMediaSession = new SIPSorcery.Media.VoIPMediaSession(winAudio.ToMediaEndPoints());
// setup for the media session
voipMediaSession.AcceptRtpFromAny = true;
voipMediaSession.OnAudioFormatsNegotiated += (formats) => voipMediaSession.AudioExtrasSource.SetAudioSourceFormat(formats.First());
voipMediaSession.AudioExtrasSource.AudioSamplePeriodMilliseconds = 30;
bool callOk = await userAgent.Call(destination, CALLER_USER, CALLER_PW, _voipMediaSession);
Any ideas on what could cause this behaviour / what I should do differently?