Re: [asterisk-dev] PJSIP messaging : specifying the user portion of the request-URI

2021-06-16 Thread Jean Aunis

Le 16/06/2021 à 16:32, George Joseph a écrit :


On Wed, Jun 16, 2021 at 6:27 AM George Joseph > wrote:



Changes up in gerrit...

https://gerrit.asterisk.org/c/asterisk/+/16068 



Thanks. I've just tested it, with both the dialplan and AMI, and it's 
working well. The From and To headers take the appropriate values.


That's exactly the behaviour I was looking for, thanks for this great job!

I'm using a very simple PJSIP configuration with a single aor and a 
single contact, so there are probably additional cases which would be 
worth testing.



-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

Re: [asterisk-dev] PJSIP messaging : specifying the user portion of the request-URI

2021-06-16 Thread George Joseph
On Wed, Jun 16, 2021 at 6:27 AM George Joseph  wrote:

>
>
> On Wed, Jun 16, 2021 at 12:50 AM Jean Aunis  wrote:
>
>> Le 15/06/2021 à 15:28, George Joseph a écrit :
>>
>> [2021-06-15 10:42:49.885] WARNING[5163]: res_pjsip_messaging.c:247
>>
>>> insert_user_in_contact_uri: Dest: 'PJSIP/3200@linphone' MSG SEND FAIL:
>>> There's already a username in endpoint linphone's contact URI
>>> 'sip:linphone@127.0.0.1:5063;line=068b0910396d2ed'.
>>> [2021-06-15 10:42:49.885] ERROR[5163]: res_pjsip_messaging.c:1240
>>
>>
>>
>> Yeah that's the expected behavior although I guess I can change it.  I
>> figured that if there was a user already specified in the contact uri that
>> overwriting it with something else was probably not a good idea.Now
>> that I think of it though, I was thinking more from sending messages
>> upstream to a provider not downstream to a client.
>>
>> So what should the behavior be?  To construct the Request URI replace any
>> user in the contact URI with the user or number specified in the
>> MessageSend call?
>>
>> I would be in favour of trusting the dialplan. If someone wants to send a
>> message to an endpoint with a specific number, that should be possible.
>> That looks more flexible to me.
>>
> I should have a patch up for that in a few hours.
>


Changes up in gerrit...

https://gerrit.asterisk.org/c/asterisk/+/16068



>
>
>> By the way, I'm fine with the modification of MessageSend you describe.
>> What about applying the same modification to the MessageSend AMI action and
>> to the sendMessage / sendMessageToEndpoint requests in ARI ?
>>
> The Message related AMI and ARI stuff call the same core functions so
> they automatically support the "PJSIP/" form of the destination as well as
> the refactored parsing code for the rest of the destination forms.   Adding
> the third "to" parameter that was added to the dialplan app is a little
> more problematic for AMI and ARI.  Dialplan apps don't have named
> parameters so adding the third one was no problem.  Both the AMI and ARI
> calls have named parameters and the first one is already named "to" so
> renaming that one to "destination" and adding "to" would break the contract
> in Asterisk 16 and 18.   I can, and will, make that change for For Asterisk
> 19 however,
>
>
>> --
>> _
>> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>>
>> asterisk-dev mailing list
>> To UNSUBSCRIBE or update options visit:
>>http://lists.digium.com/mailman/listinfo/asterisk-dev
>
>
-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

Re: [asterisk-dev] PJSIP messaging : specifying the user portion of the request-URI

2021-06-16 Thread George Joseph
On Wed, Jun 16, 2021 at 12:50 AM Jean Aunis  wrote:

> Le 15/06/2021 à 15:28, George Joseph a écrit :
>
> [2021-06-15 10:42:49.885] WARNING[5163]: res_pjsip_messaging.c:247
>
>> insert_user_in_contact_uri: Dest: 'PJSIP/3200@linphone' MSG SEND FAIL:
>> There's already a username in endpoint linphone's contact URI
>> 'sip:linphone@127.0.0.1:5063;line=068b0910396d2ed'.
>> [2021-06-15 10:42:49.885] ERROR[5163]: res_pjsip_messaging.c:1240
>
>
>
> Yeah that's the expected behavior although I guess I can change it.  I
> figured that if there was a user already specified in the contact uri that
> overwriting it with something else was probably not a good idea.Now
> that I think of it though, I was thinking more from sending messages
> upstream to a provider not downstream to a client.
>
> So what should the behavior be?  To construct the Request URI replace any
> user in the contact URI with the user or number specified in the
> MessageSend call?
>
> I would be in favour of trusting the dialplan. If someone wants to send a
> message to an endpoint with a specific number, that should be possible.
> That looks more flexible to me.
>
I should have a patch up for that in a few hours.


> By the way, I'm fine with the modification of MessageSend you describe.
> What about applying the same modification to the MessageSend AMI action and
> to the sendMessage / sendMessageToEndpoint requests in ARI ?
>
The Message related AMI and ARI stuff call the same core functions so
they automatically support the "PJSIP/" form of the destination as well as
the refactored parsing code for the rest of the destination forms.   Adding
the third "to" parameter that was added to the dialplan app is a little
more problematic for AMI and ARI.  Dialplan apps don't have named
parameters so adding the third one was no problem.  Both the AMI and ARI
calls have named parameters and the first one is already named "to" so
renaming that one to "destination" and adding "to" would break the contract
in Asterisk 16 and 18.   I can, and will, make that change for For Asterisk
19 however,


> --
> _
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
>http://lists.digium.com/mailman/listinfo/asterisk-dev
-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

Re: [asterisk-dev] PJSIP messaging : specifying the user portion of the request-URI

2021-06-16 Thread Jean Aunis

Le 15/06/2021 à 15:28, George Joseph a écrit :

[2021-06-15 10:42:49.885] WARNING[5163]: res_pjsip_messaging.c:247

insert_user_in_contact_uri: Dest: 'PJSIP/3200@linphone' MSG SEND
FAIL:
There's already a username in endpoint linphone's contact URI
'sip:linphone@127.0.0.1:5063
;line=068b0910396d2ed'.
[2021-06-15 10:42:49.885] ERROR[5163]: res_pjsip_messaging.c:1240



Yeah that's the expected behavior although I guess I can change it.  I 
figured that if there was a user already specified in the contact uri 
that overwriting it with something else was probably not a good idea.  
  Now that I think of it though, I was thinking more from sending 
messages upstream to a provider not downstream to a client.


So what should the behavior be?  To construct the Request URI replace 
any user in the contact URI with the user or number specified in the 
MessageSend call?


I would be in favour of trusting the dialplan. If someone wants to send 
a message to an endpoint with a specific number, that should be 
possible. That looks more flexible to me.


By the way, I'm fine with the modification of MessageSend you describe. 
What about applying the same modification to the MessageSend AMI action 
and to the sendMessage / sendMessageToEndpoint requests in ARI ?


-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

Re: [asterisk-dev] PJSIP messaging : specifying the user portion of the request-URI

2021-06-15 Thread George Joseph
On Tue, Jun 15, 2021 at 2:49 AM Jean Aunis  wrote:

> Le 09/06/2021 à 16:18, George Joseph a écrit :
> > Hi Guys,
> >
> > The change for allowing a dialstring-like destination in MessageSend
> > (pjsip only) is now committed in the 16, 18 and master branches.  You
> > can now use MessageSend(pjsip:PJSIP/@) and
> > the request URI will be composed of the endpoint's contact uri with
> > the number inserted as the user portion of the uri. Please give it a
> test.
> >
> > For Asterisk 19 (not an LTS release) what would you guys think of
> > changing the MessageSend application to accept discrete parameters for
> > destination uri, endpoint, user, etc.?  This would remove about 400
> > lines of fuzzy parsing code and give you the most flexibility in
> > constructing a destination.
>
> Hi George,
>
> I've just tested this with the latest version on branch 16.
>
> I have a SIP phone "linphone" performing an inbound registration, and I
> try to send a message to it with the following dialplan:
>
> exten = 800,1,Set(MESSAGE(body)=test)
> same  = n,MessageSend(pjsip:PJSIP/3200@linphone,8000)
>
> The test fails. The SIP MESSAGE is not sent and the following errors are
> displayed:
>
> *CLI> channel originate Local/800@default application Hangup
> *CLI> -- Executing [800@default:1]
> Set("Local/800@default-;2", "MESSAGE(body)=test") in new stack
>  -- Called 800@default
>  -- Executing [800@default:2]
> MessageSend("Local/800@default-;2",
> "pjsip:PJSIP/3200@linphone,8000") in new stack
> [2021-06-15 10:42:49.885] WARNING[5163]: res_pjsip_messaging.c:247
> insert_user_in_contact_uri: Dest: 'PJSIP/3200@linphone' MSG SEND FAIL:
> There's already a username in endpoint linphone's contact URI
> 'sip:linphone@127.0.0.1:5063;line=068b0910396d2ed'.
> [2021-06-15 10:42:49.885] ERROR[5163]: res_pjsip_messaging.c:1240



Yeah that's the expected behavior although I guess I can change it.  I
figured that if there was a user already specified in the contact uri that
overwriting it with something else was probably not a good idea.Now
that I think of it though, I was thinking more from sending messages
upstream to a provider not downstream to a client.

So what should the behavior be?  To construct the Request URI replace any
user in the contact URI with the user or number specified in the
MessageSend call?



>
> msg_send: PJSIP MESSAGE - Could not find endpoint 'PJSIP/3200@linphone'
> and no default outbound endpoint configured
>  -- Auto fallthrough, channel 'Local/800@default-;2' status
> is 'UNKNOWN'
>
> I can provide logs if you need.
>
> Regards,
>
> Jean
>
>
>
>
> --
> _
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
>http://lists.digium.com/mailman/listinfo/asterisk-dev
-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

Re: [asterisk-dev] PJSIP messaging : specifying the user portion of the request-URI

2021-06-15 Thread Jean Aunis

Le 09/06/2021 à 16:18, George Joseph a écrit :

Hi Guys,

The change for allowing a dialstring-like destination in MessageSend 
(pjsip only) is now committed in the 16, 18 and master branches.  You 
can now use MessageSend(pjsip:PJSIP/@) and 
the request URI will be composed of the endpoint's contact uri with 
the number inserted as the user portion of the uri. Please give it a test.


For Asterisk 19 (not an LTS release) what would you guys think of 
changing the MessageSend application to accept discrete parameters for 
destination uri, endpoint, user, etc.?  This would remove about 400 
lines of fuzzy parsing code and give you the most flexibility in 
constructing a destination.


Hi George,

I've just tested this with the latest version on branch 16.

I have a SIP phone "linphone" performing an inbound registration, and I 
try to send a message to it with the following dialplan:


exten = 800,1,Set(MESSAGE(body)=test)
same  = n,MessageSend(pjsip:PJSIP/3200@linphone,8000)

The test fails. The SIP MESSAGE is not sent and the following errors are 
displayed:


*CLI> channel originate Local/800@default application Hangup
*CLI> -- Executing [800@default:1] 
Set("Local/800@default-;2", "MESSAGE(body)=test") in new stack

    -- Called 800@default
    -- Executing [800@default:2] 
MessageSend("Local/800@default-;2", 
"pjsip:PJSIP/3200@linphone,8000") in new stack
[2021-06-15 10:42:49.885] WARNING[5163]: res_pjsip_messaging.c:247 
insert_user_in_contact_uri: Dest: 'PJSIP/3200@linphone' MSG SEND FAIL: 
There's already a username in endpoint linphone's contact URI 
'sip:linphone@127.0.0.1:5063;line=068b0910396d2ed'.
[2021-06-15 10:42:49.885] ERROR[5163]: res_pjsip_messaging.c:1240 
msg_send: PJSIP MESSAGE - Could not find endpoint 'PJSIP/3200@linphone' 
and no default outbound endpoint configured
    -- Auto fallthrough, channel 'Local/800@default-;2' status 
is 'UNKNOWN'


I can provide logs if you need.

Regards,

Jean




--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-dev

Re: [asterisk-dev] PJSIP messaging : specifying the user portion of the request-URI

2021-06-09 Thread George Joseph
Hi Guys,

The change for allowing a dialstring-like destination in MessageSend (pjsip
only) is now committed in the 16, 18 and master branches.  You can now use
MessageSend(pjsip:PJSIP/@) and the request URI
will be composed of the endpoint's contact uri with the number inserted as
the user portion of the uri.  Please give it a test.

For Asterisk 19 (not an LTS release) what would you guys think of changing
the MessageSend application to accept discrete parameters for destination
uri, endpoint, user, etc.?  This would remove about 400 lines of fuzzy
parsing code and give you the most flexibility in constructing a
destination.

On Tue, May 4, 2021 at 12:30 PM George Joseph  wrote:

>
>
> On Tue, May 4, 2021 at 8:49 AM Jean Aunis  wrote:
>
>> Hi,
>>
>> I'm trying to send a SIP MESSAGE to a PJSIP endpoint, while specifying a
>> destination number (that is, the "user" portion of the request URI in
>> sip:u...@domain.com).
>>
>> Currently, this is only possible by specifying the full request URI. For
>> example, someone could use:
>>
>>  > MessageSend(pjsip:endpoint/sip:1000@12.0.0.1)
>>
>> to send a SIP MESSAGE to number 1000.
>>
>> But to do this, one needs to know the contact associated to the
>> endpoint. This is a problem if the endpoint is dynamically registering
>> to Asterisk: the contact information may change over time.
>>
>> When using the dialplan, there is a straightforward solution: using
>> PJSIP_DIAL_CONTACTS.
>>
>> Things become tricky when using ARI or AMI. Retrieving the contact
>> information requires sending an AMI request each time a SIP MESSAGE has
>> to be sent... this can create a lot of overhead.
>>
>> chan_sip used to solve this problem this way: when calling
>> MessageSend(sip:user@endpoint), "endpoint" was at first searched in the
>> endpoints list before being used as a FQDN or an IP address.
>>
>
> The format that PJSIP_DIAL_CONTACTS returns is
> PJSIP/user@endpoint/contact_uri
> For example
> PJSIP/8005551212@provider/sip:sip.provider.com:5060
>
> Dial() doesn't need the contact_uri  but it can be supplied.
>
> I think the easiest way to solve this is to just allow MessageSend take
> the same format as a simple dial string like so
>
> MessageSend(pjsip:PJSIP/8005551212@provider)
> "pjsip:" routes the request to the pjsip channel driver.
> "PJSIP/" tells the pjsip channel driver that what follows is formatted as a
> dial string.
>
> If you wanted to supply the contact_uri as well, you could do
> MessageSend(pjsip:PJSIP/8005551212@provider/sip:sip.provider.com:5060)
> If not, we'd take the first contact of the first aor and use that.
>
>
>>
>> I understand this is more complex with PJSIP because there may be
>> multiple AOR/ contacts for a single endpoint...
>>
>
> Yep, there's the issue and I'm not sure how to get around that other than
> the caller specifying a specific contact uri or us trying every contact for
> every aor associated to an endpoint and stopping when we get a
> 202 Message Accepted.
>
> If we can stick to the first contact on the first aor or specifying
> the specific contact uri, that's a quick  modification to my current
> patch up on gerrit.  If we have to go down the route of trying
> in turn, that's something that will need more thought.
>
>
>
>
>>
>> Any ideas ?
>>
>> Regards,
>>
>> Jean
>>
>>
>>
>> --
>> _
>> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>>
>> asterisk-dev mailing list
>> To UNSUBSCRIBE or update options visit:
>>http://lists.digium.com/mailman/listinfo/asterisk-dev
>
>
-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

Re: [asterisk-dev] PJSIP messaging : specifying the user portion of the request-URI

2021-05-05 Thread Jean Aunis

Le 04/05/2021 à 20:30, George Joseph a écrit :




I think the easiest way to solve this is to just allow MessageSend take
the same format as a simple dial string like so

MessageSend(pjsip:PJSIP/8005551212@provider)
"pjsip:" routes the request to the pjsip channel driver.
"PJSIP/" tells the pjsip channel driver that what follows is formatted 
as a

dial string.

Great, that would solve my problem. Thanks for the feedback.
-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

Re: [asterisk-dev] PJSIP messaging : specifying the user portion of the request-URI

2021-05-04 Thread George Joseph
On Tue, May 4, 2021 at 8:49 AM Jean Aunis  wrote:

> Hi,
>
> I'm trying to send a SIP MESSAGE to a PJSIP endpoint, while specifying a
> destination number (that is, the "user" portion of the request URI in
> sip:u...@domain.com).
>
> Currently, this is only possible by specifying the full request URI. For
> example, someone could use:
>
>  > MessageSend(pjsip:endpoint/sip:1000@12.0.0.1)
>
> to send a SIP MESSAGE to number 1000.
>
> But to do this, one needs to know the contact associated to the
> endpoint. This is a problem if the endpoint is dynamically registering
> to Asterisk: the contact information may change over time.
>
> When using the dialplan, there is a straightforward solution: using
> PJSIP_DIAL_CONTACTS.
>
> Things become tricky when using ARI or AMI. Retrieving the contact
> information requires sending an AMI request each time a SIP MESSAGE has
> to be sent... this can create a lot of overhead.
>
> chan_sip used to solve this problem this way: when calling
> MessageSend(sip:user@endpoint), "endpoint" was at first searched in the
> endpoints list before being used as a FQDN or an IP address.
>

The format that PJSIP_DIAL_CONTACTS returns is
PJSIP/user@endpoint/contact_uri
For example
PJSIP/8005551212@provider/sip:sip.provider.com:5060

Dial() doesn't need the contact_uri  but it can be supplied.

I think the easiest way to solve this is to just allow MessageSend take
the same format as a simple dial string like so

MessageSend(pjsip:PJSIP/8005551212@provider)
"pjsip:" routes the request to the pjsip channel driver.
"PJSIP/" tells the pjsip channel driver that what follows is formatted as a
dial string.

If you wanted to supply the contact_uri as well, you could do
MessageSend(pjsip:PJSIP/8005551212@provider/sip:sip.provider.com:5060)
If not, we'd take the first contact of the first aor and use that.


>
> I understand this is more complex with PJSIP because there may be
> multiple AOR/ contacts for a single endpoint...
>

Yep, there's the issue and I'm not sure how to get around that other than
the caller specifying a specific contact uri or us trying every contact for
every aor associated to an endpoint and stopping when we get a
202 Message Accepted.

If we can stick to the first contact on the first aor or specifying
the specific contact uri, that's a quick  modification to my current
patch up on gerrit.  If we have to go down the route of trying
in turn, that's something that will need more thought.




>
> Any ideas ?
>
> Regards,
>
> Jean
>
>
>
> --
> _
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
>http://lists.digium.com/mailman/listinfo/asterisk-dev
-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev