I have configured Asterisk 13.13.1 with PJProject 2.5.5 and enable PJSIP as SIP driver (without compiling chan_sip).
I have the fully configured system and it's working but I have some problems with incoming calls. I have few numbers connected with my host and when I calling from any public number I noticed this info on asterisk remote console:
[Feb 24 14:27:16] NOTICE[5291]: res_pjsip/pjsip_distributor.c:525 log_failed_request: Request 'INVITE' from '"zzzzz" <sip:zzzzz#192.168.34.1>' failed for '192.168.34.1:5062' (callid: 0e07e7607f8f62dd225347363173bb9f#192.168.34.1:5062) - No matching endpoint found
And if I add the number which is calling to my Asterisk to endpoints then it's working - I can pick up this call.
How to add the possibility to allow all inbound calls?
You need to create an anonymous endpoint to accept inbound calls from unknown endpoints.
Be aware that adding an anonymous endpoint opens the system to extension scanning attacks where scanners try to find out which extensions you have configured in your system. They do this either to spam you with advertising calls, or exploit call transferring to call long distance numbers, or for some other ulterior motive.
After creating an anonymous endpoint, associate it with a context different from that used by your extensions. This prevents them from dialing long-distance through your trunks.
To add an anonymous endpoint in pjsip.conf, add the following lines:
[anonymous]
type=endpoint
context=anonymous
disallow=all
allow=speex,g726,g722,ilbc,gsm,alaw
In the dialplan extensions.conf:
[anonymous]
exten => _XXXXX,1,GotoIf(${DIALPLAN_EXISTS(local-extensions,${EXTEN},1)}?local-extensions,${EXTEN},1)
same => n,Hangup(1)
local-extensions is the context listing your local extensions.
It looks like your missing something from you pjsip config. My basic config is as follows and is based on a sipgate setup with an internal extension. This config has been extracted from a running box (though usernames & passwords have been removed);
pjsip.conf
[transport-udp]
type = transport
protocol = udp
bind = 0.0.0.0
[reg_sipgate_premium]
type = registration
retry_interval = 20
max_retries = 10
contact_user = 0000000
expiration = 120
transport = transport-udp
outbound_auth = auth_sipgate_premium
client_uri = sip:0000000#sipgate.co.uk:5060
server_uri = sip:sipgate.co.uk:5060
[auth_sipgate_premium]
type = auth
username = 0000000
password = password
[sipgate_aor_premium]
type = aor
contact = sip:0000000#sipgate.co.uk
[sipgate-preimum]
type = endpoint
context = incomingsipgate
dtmf_mode = rfc4733
disallow = all
allow = alaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
timers = yes
from_user = 0000000
from_domain = sipgate.co.uk
language = en
outbound_auth = auth_sipgate_premium
aors = sipgate_aor_premium
extensions.conf
[incomingsipgate]
exten => 0000000,1,Goto(sipgate-in-premium,0000000,1)
[sipgate-in-premium]
exten => 0000000,1,Verbose(Incoming call from Sipgate line CallerID=${CALLERID(all)})
exten => 0000000,2,Goto(internal-ext,120,1)
[internal-ext]
exten => 120,1,Dial(SCCP/120,20,o,CallerID=${CALLERID(all)})
This line is used to catch any free phone (0500) number and route it via sipgate when a user internally dials 90500xxxxxxx;
exten => _90500.,1,Dial(PJSIP/${EXTEN:1}#sipgate-preimum)
For sure, the problem is in your incoming line operator context. The problem is not in pjsip - it is in dialplan. Please check your trunk (or registration context value to understand proper dialplan section:
[outer]
exten=>_1234567,1,NoOp(Incoming call to public number 1234567)
exten=>_1234567,n,GoTo(outer,3333,1)
exten=>_1234567,n,Hangup()
exten=>_3333,1,NoOp(Transfered from public context to local extension 3333)
exten=>_3333,n,Dial(PJSIP/${EXTEN},180)
exten=>_3333,n,Hangup()
Change 1234567 to your public number and 3333 to the local number that has to receive this incoming call. And of course, set outer as context for incoming calls number provider registration (trunk).
Related
Im using C# AsterNET to manage my Asterisk commands and events, and now I do have a new feature to work on.
This is simple (I think) but I'm stucked right now.
Scenario
I do have two queues, 8100 and 8300, and 2 extensions being 8101 and 8301. When I do have a call from PSTN it is driven to 8100 queue. When the 8101 extension become available I do add this extension to the 8100 queue, so the calling PSTN device will be redirected to this 8101 extension.
Everything is working fine till here.
Sometimes I do park the calling device and let 8301 knows it using my app, so 8301 user using the same app can send a command asking for that parked channel to be redirect to his SIP Phone. Also working fine.
Scope
Now I want to have some feature to let 8101 transfer this calling device to my other queue, the 8300. So I just tried to reuse my parked method and redirect method
internal void Park(string channel, int parkTimeout)
{
ParkAction pa = new ParkAction(channel, channel, parkTimeout.ToString());
ManagerResponse mr = manager.SendAction(pa);
}
internal void RedirectFromParking(string channel, string exten)
{
RedirectAction ra = new RedirectAction
{
Priority = 1,
Context = "default",
Channel = channel,
Exten = exten
};
ManagerResponse mr = manager.SendAction(ra);
}
Park("abc123456", 10000);
RedirectFromParking("abc123456", "8300")
Issue
I'm parking fine but when I try to redirect from parking to my queue the calling device is just disconnected and the connection is lost.
How can I transfer a parked call to my queue or transfer it directly to the queue (would be better) without needing to originate?
Just do hold instead of parking and make your own list of such calls.
To transfer to a queue I can do a blind transfer as documented on Asterisk website. Links below:
ManagerAction_BlindTransfer
ManagerEvent_BlindTransfer
To achieve this using AsterNET, I can use the same RedirectAction I was using but I do need to change the context. It can't be default for context, as default we are letting Asterisk manage it and somehow it can't handle as I expetected. So it need to be clearly specified as internar transfer. The event raised after this context transfer is the Manager_BlindTransfer.
Manager_Action_RedirectAction
So using my SIP Phone I manage to transfer a call while I was debugging that raised event method, so I could catch the context used in. Using the correct context
ManagerConnection manager = new ManagerConnection(address, port, user, password);
manager.BlindTransfer += Manager_BlindTransfer;
private void Manager_BlindTransfer(object sender, BlindTransferEvent e)
{
}
After this I created another method to transfer to directly to a queue using the correct context.
internal void TransferToQueue(string channel, string queue)
{
RedirectAction ma = new RedirectAction
{
Priority = priority,
Context = "from-internal-xfer",
Channel = channel,
Exten = queue
};
ManagerResponse mr = manager.SendAction(ma);
}
TransferToQueue("abc123456", "8300")
Summary
Was just a matter of the correct context to be used in.
from-internal-xfer
I have set up FreePbx and it is working I can make calls into the pbx and out of the pbx. I have enabled the REST API and added a user and password. I cloned the Asternet.Ari https://github.com/skrusty/AsterNET.ARI.
The program runs and I get the connected event:
// Create a new Ari Connection
ActionClient = new AriClient(
new StasisEndpoint("192.168.1.14", 8088, "userId", "password"),
"HelloWorld");
// Hook into required events
ActionClient.OnStasisStartEvent += c_OnStasisStartEvent;
ActionClient.OnChannelDtmfReceivedEvent += ActionClientOnChannelDtmfReceivedEvent;
ActionClient.OnConnectionStateChanged += ActionClientOnConnectionStateChanged;
ActionClient.OnChannelCallerIdEvent += ActionClient_OnChannelCallerIdEvent;
ActionClient.Connect();
........
private static void ActionClientOnConnectionStateChanged(object sender)
{
Console.WriteLine("Connection state is now {0}", ActionClient.Connected);
}
The ActionClient is connected.
I then call in to a extension but nothing happens. I do not get any other events. Should an event fire when any extension is called? Not sure if I have set the pbx up correctly. I do not get any calling events when I call in from soft phone or from outside Lan on a cell phone.
Long time have passed but maybe useful yet.
Just set subscribeAllEvents argument to true.
ActionClient = new AriClient(
new StasisEndpoint("voip", 8088, "root", "password"),
"HelloWorld",
true);
Well your Asterisk Ari is connecting, but to get anything in it, you have to create Extension so your call go to Stasis application.
Please edit your extensions.conf file with following information
exten => _1XX,1,NoOp()
same => n,Stasis(HelloWorld,PJSIP/${EXTEN}, 45)
same => n,Hangup()
This script first check any incoming number which starts with 1 will be forawarded to your ARI script. HelloWorld is name of app so you alread have it in your script. Now any call come it will show whole information on your socket. Now you have to handle this information to any specific task.
\
I need to test behavior of the feature which depends on the users IP address. The user should be redirected to different pages depending on his IP address.
I create client like that: $this->client = static::createClient();
Is there any way to do that?
Try to create different clients:
$this->client1 = static::createClient([], ['REMOTE_ADDR' => '11.11.11.11']);
$this->client2 = static::createClient([], ['REMOTE_ADDR' => '22.22.22.22']);
I am trying to learn how i can add call forwarding facility for few phones by default in Asterisk via conf files entries. My Asterisk version 1.6.2.6
I read http://www.voip-info.org/wiki/view/Asterisk+call+forwarding
In my scenario i have 3 entries like 10,11,12 which always answer the calls.
But i am trying to do call forwarding ie if 10 busy then call should go to 11, if 11 busy then call goes to 12,if 12 then call end with recorded tape that 'all are busy'.
For that i read above link data, as per my knowledge i have to change my dial plan. but in examples all showing first i should click # key & save it. but i need by default call forwarding. As if phone 50 calls 10 then if 10 not busy then it goes to 10 only. But if 51 calls 10 then it goes to 11 because 10 busy with 50.
I am giving example of phone 10 entries in Asterisk conf files same for other also.
My extension.conf entries:
exten => 0010,2,Queue(0010)
exten => 0110,1,Dial(SIP/0110)
exten => 0210,1,Dial(SIP/0210)
My sip.conf entries:
[0010]
username = 0010
secret = 0010
type = friend
insecure = port,invite
host = dynamic
context = users
[0110]
username = 0110
secret = 0110
type = friend
insecure = port,invite
host = dynamic
context = users
[0210]
username = 0210
secret = 0210
type = friend
insecure = port,invite
host = dynamic
context = users
My queues.conf entries:-
[0010]
member => SIP/0010
Where & what i should add in above entries so call forwarding done in my Asterisk?
Please check this book
http://www.asteriskdocs.org/en/3rd_Edition/asterisk-book-html/asterisk-book.html#asterisk-ACD
Or this book
http://cdn.oreilly.com/books/9780596510480.pdf
Both have full description for your case.
I'm using Asterisk 10,centos 6. and I'V done changes in conf file as below for call forwarding
"extension.conf"
exten => 0010,1,Wait(0.05)
exten => 0010,2,Queue(0010)
exten => 0010,n,Dial(SIP/0011,15)
exten => 0010,n,Dial(SIP/0012,15)
exten => 0110,1,Dial(SIP/0110)
exten => 0210,1,Dial(SIP/0210)
"queues.conf"
;----------------------QUEUE TIMING OPTIONS------------------------------------
timeout = 15
retry = 5
;timeoutpriority = app|conf
timeoutpriority = conf
[0010]
member => SIP/0010
[0011]
member => SIP/0011
[0012]
member => SIP/0012
Please suggest wheather i'm right if not then please suggest some answer based on given .conf files
I am using the new Akka IO and followed this tutorial(which is a simple server-client application). My server actor system code looks like this:
// create the sever system
ActorSystem tcpServerSystem = ActorSystem.create("tcp-server-system");
// create the tcp actor
final ActorRef tcpServer = Tcp.get(tcpServerSystem).manager();
// create the server actor;
ActorRef serverActor = tcpServerSystem.actorOf(new Props(ServerActor.class).withRouter(new RoundRobinRouter(5)), "server");
// tell the tcp server to use an actor for listen connection on;
final List<Inet.SocketOption> options = new ArrayList<Inet.SocketOption>();
options.add(TcpSO.reuseAddress(true));
tcpServer.tell(TcpMessage.bind(serverActor, new InetSocketAddress("127.0.0.1", 12345), 10, options),
serverActor);
The ServerActor class it's just a plain actor that on it's onReceive does the followings:
logger.info("Received: " + o);
if (o instanceof Tcp.Connected){
connectionActor = getSender();
connectionActor.tell(TcpMessage.register(getSelf()), getSelf());
ByteStringBuilder byteStringBuilder = new ByteStringBuilder();
byteStringBuilder.putBytes("Hello Worlds".getBytes());
connectionActor.tell(TcpMessage.write(byteStringBuilder.result()), getSelf());
}
I am trying to test the server actor using netcat and have this "strange" behaviour: only the first client that connect tot the server is receiving the message send from the server. The nexts clients could connect to the server but does not receive the message. Also in debug mode the server actor doesn't get the Tcp.Connected message(except for the first connected client), so a registration message could not be sent to the client, althought the next clients could connect.
this is a known issue in the 2.2-M1 milestone, where the problem was that the TcpListener didn't register AcceptInterest on the selector unless it reached the configured BatchAcceptLimit, leading to it not being notified of new accepts if there where only a few connections pending.
It has been fixed and will be part of the next milestone release.