Endpoint handler

Hi everyone,

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?

Thanks for your time on checking my topic

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.

1 Like

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.

the endpoint is result of command

pjsip list endpoints

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

Those are configured PJSIP endpoints in pjsip.conf which define the configuration to use when talking to a remote SIP device or provider.

That still doesn’t define what an endpoint means to you and what you are actually trying to do.

Are you writing an application that runs on a computer that connects over SIP to Asterisk?

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.

I still don’t know what you’re really wanting. Someone else may be able to provide input.

basically in short, we want to connect to a SIP provider and make outbound call to external phone and receive inbound call.

Then you configure pjsip.conf with the required configuration to connect to a SIP provider, and use it as the target for a call.

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?

Yes. Though that is not the correct format for PJSIP.

The correct format would be:

PJSIP/+1234567890@commio-trunk2
1 Like

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

So the destination phone is missing.

I don’t know anything about asterisk-java. PJSIP configuration also plays a part in what is done, so you would also need to provide that.

Here is PJIP configuration

pjsip.endpoint_custom.conf

[commio-trunk2]
type=endpoint
transport=0.0.0.0-udp
context=from-pstn
disallow=all
allow=ulaw,alaw,g729,gsm,g726,g722,h264,mpeg4
aors=commio-trunk2
send_connected_line=false
language=en
user_eq_phone=no
t38_udptl=no
t38_udptl_ec=none
fax_detect=no
trust_id_inbound=no
t38_udptl_nat=no
direct_media=no
rtp_symmetric=yes
dtmf_mode=auto
type=aor

pjsip.aor.conf

[commio-trunk2]
type=aor
qualify_frequency=60
contact=sip:provider.com:5060

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.

1 Like

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.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.