CyCoreSystems / asterisk-config

Kubernetes dynamic configuration engine for Asterisk
Other
62 stars 25 forks source link

Asterisk Applications are not Loaded if Cloud is not Set #2

Open adrianhumphrey111 opened 5 years ago

adrianhumphrey111 commented 5 years ago

Hello,

I am currently trying to get this up and running on Amazon EKS and it is working for the most part. The only problem is if I do not specify a cloud, and run "core show applications" inside of the asterisk cli, these are the applications that I get:


              Answer: Answer a channel if ringing.
            BackGround: Play an audio file while waiting for digits of an extension to go to.
                Bridge: Bridge two channels.
            BridgeWait: Put a call into the holding bridge.
                  Busy: Indicate the Busy condition.
  CallCompletionCancel: Cancel call completion service
  CallCompletionRequest: Request call completion service for previous call
             ClearHash: Clear the keys from a specified hashname.
            ConfBridge: Conference bridge application.
            Congestion: Indicate the Congestion condition.
                  Dial: Attempt to connect to another device or endpoint and bridge the call.
             Directory: Provide directory of voicemail extensions.
            ExecIfTime: Conditional application execution based on the current time.
                 Gosub: Jump to label, saving return address.
               GosubIf: Conditionally jump to label, saving return address.
                  Goto: Jump to a particular priority, extension, or context.
                GotoIf: Conditional goto.
            GotoIfTime: Conditional Goto based on the current time.
                Hangup: Hang up the calling channel.
             ImportVar: Import a variable from a channel into a new variable.
            Incomplete: Returns AST_PBX_INCOMPLETE value.
                   Log: Send arbitrary text to a selected log level.
         MailboxExists: Check to see if Voicemail mailbox exists.
           MessageSend: Send a text message.
                  MSet: Set channel variable(s) or function value(s).
           MusicOnHold: Play Music On Hold indefinitely.
                  NoOp: Do Nothing (No Operation).
              Playback: Play a file.
            Proceeding: Indicate proceeding.
              Progress: Indicate progress.
        RaiseException: Handle an exceptional condition.
             RetryDial: Place a call, retrying on failure allowing an optional exit extension.
                Return: Return from gosub routine.
               Ringing: Indicate ringing tone.
              SayAlpha: Say Alpha.
          SayAlphaCase: Say Alpha.
             SayDigits: Say Digits.
             SayNumber: Say Number.
           SayPhonetic: Say Phonetic.
                   Set: Set channel variable or function value.
           SetAMAFlags: Set the AMA Flags.
              StackPop: Remove one address from gosub stack.
      StartMusicOnHold: Play Music On Hold.
                Stasis: Invoke an external Stasis application.
       StopMusicOnHold: Stop playing Music On Hold.
               Verbose: Send arbitrary text to verbose output.
        VMAuthenticate: Authenticate with Voicemail passwords.
             VMSayName: Play the name of a voicemail user
             VoiceMail: Leave a Voicemail message.
         VoiceMailMain: Check Voicemail messages.
      VoiceMailPlayMsg: Play a single voice mail msg from a mailbox by msg id.
                  Wait: Waits for some time.
             WaitDigit: Waits for a digit to be entered.
             WaitExten: Waits for an extension to be entered.
    -= 54 Applications Registered =-
asterisk-585c5c4ff4-6nqz5*CLI> core show applications
    -= Registered Asterisk Applications =-
              ADSIProg: Load Asterisk ADSI Scripts into phone
                AELSub: Launch subroutine built with AEL
                   AGI: Executes an AGI compliant application.
                Answer: Answer a channel if ringing.
           AudioSocket: Transmit and receive audio between channel and TCP socket
          Authenticate: Authenticate a user
            BackGround: Play an audio file while waiting for digits of an extension to go to.
      BackgroundDetect: Background a file with talk detect.
                Bridge: Bridge two channels.
             BridgeAdd: Join a bridge that contains the specified channel.
            BridgeWait: Put a call into the holding bridge.
                  Busy: Indicate the Busy condition.
  CallCompletionCancel: Cancel call completion service
  CallCompletionRequest: Request call completion service for previous call
       CELGenUserEvent: Generates a CEL User Defined Event.
         ChangeMonitor: Change monitoring filename of a channel.
           ChanIsAvail: Check channel availability
       ChannelRedirect: Redirects given channel to a dialplan target
               ChanSpy: Listen to a channel, and optionally whisper into it.
             ClearHash: Clear the keys from a specified hashname.
            ConfBridge: Conference bridge application.
            Congestion: Indicate the Congestion condition.
         ContinueWhile: Restart a While loop.
       ControlPlayback: Play a file with fast forward and rewind.
             DAHDIScan: Scan DAHDI channels to monitor calls.
              DateTime: Says a specified time in a custom format.
                 DBdel: Delete a key from the asterisk database.
             DBdeltree: Delete a family or keytree from the asterisk database.
               DeadAGI: Executes AGI on a hungup channel.
                  Dial: Attempt to connect to another device or endpoint and bridge the call.
               Dictate: Virtual Dictation Machine.
             Directory: Provide directory of voicemail extensions.
                  DISA: Direct Inward System Access.
              DumpChan: Dump Info About The Calling Channel.
                  EAGI: Executes an EAGI compliant application.
                  Echo: Echo media, DTMF back to the calling party
              EndWhile: End a while loop.
                  Exec: Executes dialplan application.
                ExecIf: Executes dialplan application, conditionally.
            ExecIfTime: Conditional application execution based on the current time.
             ExitWhile: End a While loop.
              ExtenSpy: Listen to a channel, and optionally whisper into it.
           ExternalIVR: Interfaces with an external IVR application.
               ForkCDR: Forks the current Call Data Record for this channel.
              GetCPEID: Get ADSI CPE ID.
                 Gosub: Jump to label, saving return address.
               GosubIf: Conditionally jump to label, saving return address.
                  Goto: Jump to a particular priority, extension, or context.
                GotoIf: Conditional goto.
            GotoIfTime: Conditional Goto based on the current time.
                Hangup: Hang up the calling channel.
      HangupCauseClear: Clears hangup cause information from the channel that is available through HANGUPCAUSE.
                  ICES: Encode and stream using 'ices'.
             ImportVar: Import a variable from a channel into a new variable.
            Incomplete: Returns AST_PBX_INCOMPLETE value.
                   Log: Send arbitrary text to a selected log level.
                 Macro: Macro Implementation.
        MacroExclusive: Exclusive Macro Implementation.
             MacroExit: Exit from Macro.
               MacroIf: Conditional Macro implementation.
         MailboxExists: Check to see if Voicemail mailbox exists.
           MessageSend: Send a text message.
             Milliwatt: Generate a Constant 1004Hz tone at 0dbm (mu-law).
         MinivmAccMess: Record account specific messages.
          MinivmDelete: Delete Mini-Voicemail voicemail messages.
           MinivmGreet: Play Mini-Voicemail prompts.
             MinivmMWI: Send Message Waiting Notification to subscriber(s) of mailbox.
          MinivmNotify: Notify voicemail owner about new messages.
          MinivmRecord: Receive Mini-Voicemail and forward via e-mail.
            MixMonitor: Record a call and mix the audio during the recording.  Use of StopMixMonitor is required to guarantee the audio file is available for processing during dialplan execution.
               Monitor: Monitor a channel.
             Morsecode: Plays morse code.
             MP3Player: Play an MP3 file or M3U playlist file or stream.
                  MSet: Set channel variable(s) or function value(s).
           MusicOnHold: Play Music On Hold indefinitely.
                NBScat: Play an NBS local stream.
                 NoCDR: Tell Asterisk to not maintain a CDR for this channel.
                  NoOp: Do Nothing (No Operation).
             Originate: Originate a call.
                  Page: Page series of phones
          PauseMonitor: Pause monitoring of a channel.
                Pickup: Directed extension call pickup.
            PickupChan: Pickup a ringing channel.
              Playback: Play a file.
             PlayTones: Play a tone list.
        PrivacyManager: Require phone number to be entered, if no CallerID sent
            Proceeding: Indicate proceeding.
              Progress: Indicate progress.
        RaiseException: Handle an exceptional condition.
                  Read: Read a variable.
             ReadExten: Read an extension into a variable.
            ReceiveFAX: Receive a FAX and save as a TIFF/F file.
                Record: Record to a file.
              ResetCDR: Resets the Call Data Record.
             RetryDial: Place a call, retrying on failure allowing an optional exit extension.
                Return: Return from gosub routine.
               Ringing: Indicate ringing tone.
              SayAlpha: Say Alpha.
          SayAlphaCase: Say Alpha.
             SayDigits: Say Digits.
             SayNumber: Say Number.
           SayPhonetic: Say Phonetic.
           SayUnixTime: Says a specified time in a custom format.
              SendDTMF: Sends arbitrary DTMF digits
               SendFAX: Sends a specified TIFF/F file as a FAX.
             SendImage: Sends an image file.
              SendText: Send a Text Message on a channel.
               SendURL: Send a URL.
                   Set: Set channel variable or function value.
           SetAMAFlags: Set the AMA Flags.
                   SMS: Communicates with SMS service centres and SMS capable analogue phones.
            SoftHangup: Hangs up the requested channel.
  SpeechActivateGrammar: Activate a grammar.
      SpeechBackground: Play a sound file and wait for speech to be recognized.
          SpeechCreate: Create a Speech Structure.
  SpeechDeactivateGrammar: Deactivate a grammar.
         SpeechDestroy: End speech recognition.
     SpeechLoadGrammar: Load a grammar.
  SpeechProcessingSound: Change background processing sound.
           SpeechStart: Start recognizing voice in the audio stream.
   SpeechUnloadGrammar: Unload a grammar.
              StackPop: Remove one address from gosub stack.
      StartMusicOnHold: Play Music On Hold.
                Stasis: Invoke an external Stasis application.
        StopMixMonitor: Stop recording a call through MixMonitor, and free the recording's file handle.
           StopMonitor: Stop monitoring a channel.
       StopMusicOnHold: Stop playing Music On Hold.
         StopPlayTones: Stop playing a tone list.
            StreamEcho: Echo media, up to 'N' streams of a type, and DTMF back to the calling party
                System: Execute a system command.
            TestClient: Execute Interface Test Client.
            TestServer: Execute Interface Test Server.
              Transfer: Transfer caller to remote extension.
               TryExec: Executes dialplan application, always returning.
             TrySystem: Try executing a system command.
        UnpauseMonitor: Unpause monitoring of a channel.
             UserEvent: Send an arbitrary user-defined event to parties interested in a channel (AMI users and relevant res_stasis applications).
               Verbose: Send arbitrary text to verbose output.
        VMAuthenticate: Authenticate with Voicemail passwords.
             VMSayName: Play the name of a voicemail user
             VoiceMail: Leave a Voicemail message.
         VoiceMailMain: Check Voicemail messages.
      VoiceMailPlayMsg: Play a single voice mail msg from a mailbox by msg id.
                  Wait: Waits for some time.
             WaitDigit: Waits for a digit to be entered.
             WaitExten: Waits for an extension to be entered.
          WaitForNoise: Waits for a specified amount of noise.
           WaitForRing: Wait for Ring Application.
        WaitForSilence: Waits for a specified amount of silence.
             WaitUntil: Wait (sleep) until the current time is the given epoch.
                 While: Start a while loop.
            Zapateller: Block telemarketers with SIT.
    -= 152 Applications Registered =-

All of the Applications including the AudioSocket Application shows up. The problem is when the Audiosocket application is not registered when I do not specify the cloud, the call ends because Asterisk can not find the AudioSocket Application.

However, if I specify "aws" as the cloud, the asterisk-config container finds the wrong privateIPv4 address and puts it in the pjsip.d/k8s-asterisk-config.conf.tmpl file. So when the ACK comes from my provider, kamailio is unable to send the ACK back to the right nated ip address and the call hangs up after 32 seconds by asterisk because it never received the ACK.

I have solved this by 1) not providing it a cloud parameter. and 2) ssh into the asterisk container, running netdiscover or "hostname -I" to get the containers privateIPv4 and setting it in the pjsip.d/k8s-asterisk-config.conf.tmpl.

I would like to know, what is the best solution to get both the right ip address and to get the asterisk Audiosocket application to register?

adrianhumphrey111 commented 5 years ago

Update.

If I ssh into the container itself and run "core reload now" in the asterisk CLI, I get all of the applications.

Also, when I hang the phone up I get these errors from the asterisk-config container:

2018/11/26 20:30:57 service exited: failed to reload asterisk modules: failed to contact ARI to reload module res_pjsip.so: Put http://127.0.0.1:8088/ari/asterisk/modules/res_pjsip.so: dial tcp 127.0.0.1:8088: connect: connection refused
2018/11/26 20:30:57 running service
2018/11/26 20:30:57 engine failure encountered: http2: response body closed
2018/11/26 20:30:57 change detected
2018/11/26 20:30:57 service exited: failed to reload asterisk modules: failed to contact ARI to reload module res_pjsip.so: Put http://127.0.0.1:8088/ari/asterisk/modules/res_pjsip.so: dial tcp 127.0.0.1:8088: connect: connection refused
2018/11/26 20:30:57 running service
2018/11/26 20:30:57 change detected
2018/11/26 20:30:57 service exited: failed to reload asterisk modules: failed to contact ARI to reload module res_pjsip.so: Put http://127.0.0.1:8088/ari/asterisk/modules/res_pjsip.so: dial tcp 127.0.0.1:8088: connect: connection refused
2018/11/26 20:30:57 running service
2018/11/26 20:30:57 change detected
2018/11/26 20:30:57 service exited: failed to reload asterisk modules: failed to contact ARI to reload module res_pjsip.so: Put http://127.0.0.1:8088/ari/asterisk/modules/res_pjsip.so: dial tcp 127.0.0.1:8088: connect: connection refused
2018/11/26 20:30:57 running service
2018/11/26 20:30:58 change detected
2018/11/26 20:30:58 service exited: failed to reload asterisk modules: failed to contact ARI to reload module res_pjsip.so: Put http://127.0.0.1:8088/ari/asterisk/modules/res_pjsip.so: dial tcp 127.0.0.1:8088: connect: connection refused
2018/11/26 20:30:58 running service
2018/11/26 20:30:58 change detected
2018/11/26 20:30:58 service exited: failed to reload asterisk modules: failed to contact ARI to reload module res_pjsip.so: Put http://127.0.0.1:8088/ari/asterisk/modules/res_pjsip.so: dial tcp 127.0.0.1:8088: connect: connection refused
2018/11/26 20:30:58 running service
2018/11/26 20:30:58 change detected
2018/11/26 20:30:58 service exited: failed to reload asterisk modules: failed to contact ARI to reload module res_pjsip.so: Put http://127.0.0.1:8088/ari/asterisk/modules/res_pjsip.so: dial tcp 127.0.0.1:8088: connect: connection refused
2018/11/26 20:30:58 running service
2018/11/26 20:30:58 change detected
2018/11/26 20:30:58 service exited: failed to reload asterisk modules: failed to contact ARI to reload module res_pjsip.so: Put http://127.0.0.1:8088/ari/asterisk/modules/res_pjsip.so: dial tcp 127.0.0.1:8088: connect: connection refused
2018/11/26 20:30:58 running service
2018/11/26 20:30:58 change detected
2018/11/26 20:30:59 service exited: failed to reload asterisk modules: failed to contact ARI to reload module res_pjsip.so: Put http://127.0.0.1:8088/ari/asterisk/modules/res_pjsip.so: dial tcp 127.0.0.1:8088: connect: connection refused
2018/11/26 20:30:59 running service
2018/11/26 20:30:59 change detected
2018/11/26 20:30:59 service exited: failed to reload asterisk modules: failed to contact ARI to reload module res_pjsip.so: Put http://127.0.0.1:8088/ari/asterisk/modules/res_pjsip.so: dial tcp 127.0.0.1:8088: connect: connection refused
2018/11/26 20:30:59 running service
2018/11/26 20:30:59 change detected
2018/11/26 20:30:59 service exited: failed to reload asterisk modules: failed to contact ARI to reload module res_pjsip.so: Put http://127.0.0.1:8088/ari/asterisk/modules/res_pjsip.so: dial tcp 127.0.0.1:8088: connect: connection refused
2018/11/26 20:30:59 asterisk-config exiting
Ulexus commented 5 years ago

This certainly sounds like an order-of-operations problem. What Asterisk container are you using? Are you using any mitigation for staying its start on the completion of asterisk-config's first run? I usually have the entrypoint script check for the existence of one of the generated config files for this purpose.

Ulexus commented 5 years ago

See #1 for information about the order-of-operations issue.

adrianhumphrey111 commented 5 years ago

You are correct. It was an order of operations issue. I am using the Asterisk cycoresystems/asterisk image for the asterisk container. The "Network" config did not work for me. It was putting the wrong privateIPV4 address into the asterisk config file. The way I fixed this problem was create an entrypoint script to the asterisk-config dockerfile that would download netdiscover, get correct privateIPV4 and export it to an enviroment variable, then use "Env" in the template config file Works perfectly!

Ulexus commented 5 years ago

That works, but it really should work the same way with no cloud provider set, since the configuration is generated by netdiscover in the same manner.

adrianhumphrey111 commented 5 years ago

Hey, Yeah I thought so too. But for some odd reason it does not grab the right address if I specify "aws" as the cloud. A Little Background, I am testing it in AWS EKS and each node has primary and secondary privateIPv4 address. What happens is it is grabbing the correct privateIPV4 address of the node that the pod is on, however, when I ssh into the asterisk-config or asterisk containers and run netdiscover, the privateIPV4 address is different than the one that is returned by the asterisk-config template using the "Network" privateIPV4. And that address returned from netdiscover on the container always seems to be a secondary privateIPV4 address. Weird.

adrianhumphrey111 commented 5 years ago

screen shot 2018-11-29 at 12 42 40 pm

adrianhumphrey111 commented 5 years ago

Oh, yes you are also right, if I do not provide a cloud provider, the privateIPV4 address is correct, however, none of the Applications show up in Asterisk, causing asterisk not able to find the AudioSocket and disconnecting the call, however, it works if I ssh into the asterisk container and reload asterisk. Even with the check in the asterisk entrypoint. Maybe I can try I different way to have that asterisk container exit until the config is finished?

Ulexus commented 5 years ago

It sounds like I must have a bug somewhere, then. Let me take a look.

Ulexus commented 5 years ago

Do you happen to get any error messages when running with no cloud provider set? (other than the warning about not having one set)

Ulexus commented 5 years ago

I'm not finding anything which would fail with no Cloud set; in fact, I have a system in production on Azure which has to run with no cloud provider set (because their AKS networking is kind of broken), which definitely works with AudioSocket.

adrianhumphrey111 commented 5 years ago

I am unsure of exactly what is causing this for me, I think it is simply and order of operations. Not setting the cloud provider, asterisk-config container sets the correct IP address, and the asterisk container loads with the correct IP addresses, I simply need to restart asterisk. My work around was setting the cloud to AWS and simply using Environment Variables in tmpl file instead of the the Network Variables. Still unsure what would cause this. However, I really appreciate the help and the fast responses!