mikopbx / Core

Main repository! MikoPBX - is free, easy to setup PBX for small business based on Asterisk 16 core
https://www.mikopbx.com
GNU General Public License v3.0
383 stars 62 forks source link

[bug] incoming routes multiple trunk, #826

Closed answerwar closed 1 month ago

answerwar commented 1 month ago

Hello,

I tried Mikopbx and found a bug in the incoming routing configuration. I used one trunk without any issues, but when I added another trunk in incoming connections mode, there was a problem where the incoming route changed in the configuration.

[5060-incoming]
exten => _100101,1,NoOp(--- Incoming call ---)
        same => n,Set(CHANNEL(language)=en-en)
        same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)
        same => n,Set(__FROM_DID=${EXTEN})
        same => n,Set(__FROM_CHAN=${CHANNEL})
        same => n,Set(__M_CALLID=${CHANNEL(callid)})
        same => n,ExecIf($["${CHANNEL(channeltype)}" != "Local"]?Gosub(set_from_peer,s,1))
        same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Set(__FROM_PEER=${CALLERID(num)}))
        same => n,Gosub(add-trim-prefix-clid,${EXTEN},1)
        same => n,Set(__TRANSFER_OPTIONS=t)
        same => n,NoOp(contextID: ${contextID})
        same => n,ExecIf($["${CONTEXT}" == "public-direct-dial"]?Set(contextID=none-incoming))
        same => n,ExecIf($["${contextID}x" == "x"]?Set(contextID=${CONTEXT}))
        same => n,GosubIf($["${IGNORE_TIME}" != "1"]?check-out-work-time,${EXTEN},1)
        same => n,Set(IN_NEED_ANNONCE=1)

When one of the incoming trunks was turned off:

[SIP-TRUNK-2AEBAD27-incoming]
exten => _100101,1,NoOp(--- Incoming call ---)
        same => n,Set(CHANNEL(language)=en-en)
        same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)
        same => n,Set(__FROM_DID=${EXTEN})
        same => n,Set(__FROM_CHAN=${CHANNEL})
        same => n,Set(__M_CALLID=${CHANNEL(callid)})
        same => n,ExecIf($["${CHANNEL(channeltype)}" != "Local"]?Gosub(set_from_peer,s,1))
        same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Set(__FROM_PEER=${CALLERID(num)}))
        same => n,Gosub(add-trim-prefix-clid,${EXTEN},1)
        same => n,Set(__TRANSFER_OPTIONS=t)
        same => n,NoOp(contextID: ${contextID})
        same => n,ExecIf($["${CONTEXT}" == "public-direct-dial"]?Set(contextID=none-incoming))
        same => n,ExecIf($["${contextID}x" == "x"]?Set(contextID=${CONTEXT}))
        same => n,GosubIf($["${IGNORE_TIME}" != "1"]?check-out-work-time,${EXTEN},1)
        same => n,Set(IN_NEED_ANNONCE=1)
Log:
[2024-10-29 18:05:27] NOTICE[22417] res_pjsip_session.c:  SIP-TRUNK-2AEBAD27: Call (UDP:101.255.102.190:54147) to extension '100101' rejected because extension not found in context 'SIP-TRUNK-2AEBAD27-incoming'.
[2024-10-29 18:06:59] NOTICE[22417] res_pjsip_session.c:  SIP-TRUNK-2AEBAD27: Call (UDP:101.255.102.190:54147) to extension '100101' rejected because extension not found in context 'SIP-TRUNK-2AEBAD27-incoming'.
[2024-10-29 18:09:24] NOTICE[1121] res_pjsip_session.c:  SIP-TRUNK-2AEBAD27: Call (UDP:101.255.102.190:54147) to extension '100101' rejected because extension not found in context 'SIP-TRUNK-2AEBAD27-incoming'.
[2024-10-29 18:13:53] NOTICE[8112] res_pjsip_session.c:  SIP-TRUNK-2AEBAD27: Call (UDP:101.255.102.190:54147) to extension '100101' 
boffart commented 1 month ago

If two or more providers have the same IP + port, then their incoming context will be the same - this is due to the peculiarities of asterisk. the problem with the short context [5060-incoming] has been fixed in the pre-release