I'm using JsSIP to connect to FreeSwitch and then to the PSTN. I'm looking to pass the callerID in the From header. I have my code set up somewhat like this:
var TheCallerIDTest = '+33...number in E164 format';
var TheSipClient = new JsSIP.UA({....}); //works fine
var TheHandlers = {
'sending': function (e) {
var TheSipURI = new JsSIP.URI('sip', TheCallerIDTest, 'MyFreeswitchServerUrl', 5060, null, null);
var TheHeader = new JsSIP.NameAddrHeader(TheSipURI, '', null);
//displays the correct From header just fine
console.log(TheHeader);
//here's where I want to modify the INVITE request
e.from = TheHeader;
},
}
var TheCallOptions = {
'eventHandlers': TheHandlers,
'mediaConstraints': { 'audio': true, 'video': false }
};
function TestCall() {
TheSipClient.start();
TheSipClient.call("+33...E164 number", TheCallOptions);
}
Looking at the documentation, https://jssip.net/documentation/3.3.x/api/session/#event_sending, I'm hoping the add a JsSIP.NameAddrHeader
to the 'from' header of the JsSIP.OutgoingRequest INVITE
request. The console output logs the correct From header I want to add.
However, when I look at the JsSIP:RTCSession emit "sending" [request:InitialOutgoingInviteRequest
console log, it's not showing the header I want to add, and the From header that's received on the server is not the one I want to send.
What do I need to change in my code to make it work?
You need to do like this:
e.request.headers.From[0] = TheHeader;
Also probably this make sense to remove some other headers you do not want to send.