I’m newbie with the Asterisk and VoIP, so far by asterisk-java I were able to implement an AGI script server and make dial to external phone number. And I’m using softphone on Macbook for testing but there are many issues:
I can’t deploy the solution to our Linux server
Whenever i make a dial by PBX to external number, the softphone shows incoming call from the external number!!
So, How can I use asterisk-java library to implement a softphone to register an endpoint? And how many call an enpoint can handle at a time?
There is not enough information here, and some of it is conflicting. What does “implement a softphone” mean? Are you writing a softphone? If so, you wouldn’t use asterisk-java. It’s not for writing a softphone. You would use something else.
For other issues you’d need to actually provide a log or more detail. Just saying something doesn’t work is not helpful for seeking assistance.
So basically I want to handle the endpoint completely at Java backend, Is asterisk-java able to do that? If no, could you suggest some solution please?
Define what an endpoint means to you. Do you mean a SIP client or VoIP client that runs on a system? If so, then no, that is not at all what asterisk-java is for.
freepbx*CLI> pjsip list endpoints
Endpoint: <Endpoint/CID.....................................> <State.....> <Channels.>
==========================================================================================
Endpoint: 102/102 Not in use 0 of inf
Endpoint: commio-trunk2 Not in use 0 of inf
Endpoint: dpma_endpoint Unavailable 0 of inf
Objects found: 3
My java backend now is able to do these through vendor’s API:
On incoming call
Check if the call is valid (probably it calls to existing DID in our database)
Check preset condition to either
→ Forward it to a call center number
→ Play re-recorded audio
→ Hangup
On outbound call
Ringless voicemail:
→ Dial 1st call → as soon as status is changed to ringing → Dial 2nd call to same destination → As soon as 2nd call is connected to voice mail → Hangup 1st call → Place a pre-recorded audio file to voicemail
→ Failover: If 1st call gets answered → Forward to a call center number → Skip dialing 2nd call
Normal: Dial a call → if it gets connected → play pre-recorded audio
Now we are connecting to another vendor through SIP, so we want to do the same.
So lets say I have a PJSIP trunk named commio-trunk2 and external phone is +1234567890, Can I originate a call from PJSIP/commio-trunk2 to PJSIP/commio-trunk2/+1234567890?
I’m not sure if you’re faimiliar with asterisk-java but here is my code
PBXFactory.init(new AsteriskProfile());
AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX();
pbx.createAgiEntryPoint();
EndPoint from = pbx.buildEndPoint("PJSIP/commio-trunk2");
CallerID fromCallerID = pbx.buildCallerID("+11111111111", "From");
CallerID toCallerID = pbx.buildCallerID("+1234567890", "Target");
// The party we are going to call.
EndPoint to = pbx.buildEndPoint("PJSIP/+1234567890@commio-trunk2");
// Start the dial and return immediately.
// progress is provided via the ActivityCallback.
pbx.dial(from, fromCallerID, to, toCallerID, (activity, status, message) -> {
System.out.println("[" + status + "][" + message + "]");
}, "");
somehow it generates “To” for the INVITE like this:
To: <sip:provider.com>;tag=f1b86ad695fe4c8001f9345458685db0.2337
I don’t know Asterisk Java, either, but there is more information going in there than can actually be used. chan_pjsip does not allow independent control of the request URI and the To header.
Also there is redundancy between EndPoint from and EndPoint to, which confuses me.
Maybe this is some sort of click to call, with both channels being set up together, but then I’d expect the same syntax for both EndPoint x’s.
In Asterisk terminology, I think your EndPoint would be called a dial string.
That’s correct! Both from & to should be same format: PJSIP/+phone number@trunk-name.
But there is a bug in asterisk-java when they swap position of From & To in the INVITE.