Call to multiple users from a single extension fails if some of the users is unavailable

Hello,
First of all, thank you all guys for providing such a good support. I really appreciate your help.

The problem i´m facing is that i want to call to 2 users using the same extension, just one call. Apparently it´s something simple, but the problem happens if one of those users is unavailable. In this case, the call does not progress even for the user connected.

This is a bit more complex since i have all data stored in a mysql database, but i think this is not the issue.
All the users belong to the same context, and the fields of the “extension” table of the database are as follows:

  • priority: 1
  • app: dial
  • appdata: {PJSIP_DIAL_CONTACTS(user1)}&{PJSIP_DIAL_CONTACTS(user2)}

Note that I use the function PJSIP_DIAL_CONTACTS because i want to call all endpoints associated to each user. It can be more than one.
When both users are available, i can see the Dial function in the Asterisk console, all endpoints in the dialplan are properly handled:
Dial(“PJSIP/userX-00000026”, “PJSIP/user1/sip:a2d8qbkp@212.170.49.127:45834;transport=ws&PJSIP/user2/sip:flhjvsvu@212.170.49.127:62263;transport=ws”)
In this case the call progress succesfully.

But if user2 is unavailable, the console log of Asterisk shows the following:
Executing [49501568619667@default:1] Dial(“PJSIP/userX-00000029”, “PJSIP/user1/sip:flhjvsvu@212.170.49.127:62263;transport=ws&”)
WARNING[5306][C-0000001a]: app_dial.c:2449 dial_exec_full: Dial argument takes format (technology/resource)
== Spawn extension (default, 49501568619667, 1) exited non-zero on ‘PJSIP/userX-00000029’

Looking at the debug traces, the Dial function argument ends up with a weird and lonely &. Next to that & the user2´s endpoint should be inserted, but since user2 is unavailable there is nothing to add there. And the result is a call failure. No call to user1 happens.

Could you please let me know if i´m using a wrong format for the appdata field to queue different users, or if i should use a different function (different from PJSIP_DIAL_CONTACTS I mean). Or maybe there is some configuration flag for this.

Thanks a lot in advanced.
Cheers.

BTW: I´m using Asterisk 16, and all the data is stored in a mysql database.

I think you would need to explicitly test for a null response to PJSIP_DIAL_CONTACTS, and not append that user’s contacts.

Is it the normal case that there is only one contact per user?

1 Like

Thanks @david551 for your quick response.

Not really, the normal case is “several contacts per user”. (This is why i use the PJSIP_DIAL_CONTACTS function, but I´ve tried to reduce the issue as much as possible)

It seems that the function is already returning a null or empty value, which is fine since there is no available contacts for that user, but it seems it´s the “&” (which is appended anyway, i don´t know why) which is ruining the whole dial plan string.

I´m not sure what to modify to fix this. Should I edit the source code? Since the asterisk log talks about app_dial.c I guess I could dig into the source code and look for the root cause, but i think this is not a so weird or specific issue, I think I may be doing something wrong, but dont know what.

Thanks a lot.

No, I don’t think so. Please try something like this in your dial plan instead:

same = n,Set(cu=${PJSIP_DIAL_CONTACTS(user1)})
same = n,Set(PUSH(cu,&)=${PJSIP_DIAL_CONTACTS(user2)})
same = n,Dial(${cu})

Or if that PUSH() function doesn’t work with an empty string, add more dial plan to check with LEN() function, before the PUSH.

The & is there because you put it there, literally,

Thanks @penguinpbx and @david551 for your answers.

@penguinpbx, that could work, but I have everything automated using a mysql database. I´m not using the extensions.conf file, and i don´t know how to include all those instructions you mention in the database. If you could give some hints I´d really appreciate it.

@david551, you´re so rigth! that “&” is mine, is literally what I´ve written in the database field as separator between users. But this is was the only solution I found to perform a single call to several users from only one extension. This is the way I append the result of each PJSIP_DIAL_CONTACTS in order to pass a single dialplan to the dial function. Would there be another way? If so, please let me know. I have to use the database but i could change the way I use it.

Thanks a lot, team!

How are you controlling dial plan / call flow ?

Can you static a few contexts in an extensions.conf ? Then use your database logic to redirect from “default” context to a new “multidial” context ?

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