Re: [Freeswitch-users] Outbound socket PHP question
I'll see what I can do. Got a few sections of the PHP ESL to finish but should be able to write up fs_ivrd as well. -- W ___ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Re: [Freeswitch-users] Outbound socket PHP question
Thanks so much, William. This gives me a great start. -- Greg On Aug 4, 2009, at 7:04 PM, William Suffill wrote: I wrote some notes on this but have yet to wiki it. example of an outbound socket connection where the call is answered, a variable is set then perhaps play one of the pre-installed files and hangup. ivrd fs_ivrd comes with freeswitch. It being a small daemon just invokes the script defined in a variable and passes data from it via STDIN/OUT Since this is an outbound socket connections it needs to be defined in the dialplan. Ex: extension name=outbound-socket condition field=destination_number expression=^55(522)$ action application=set data=ivr_path=/usr/local/freeswitch/scripts/ivrd-demo.php/ action application=socket data=127.0.0.1:8084 async full/ /condition /extension The above dialplan sample would invoke ivr-demo.php when 55522 is called as long as fs_ivrd is running. To start fs_ivrd: /usr/local/freeswitch/bin/fs_ivrd -h 127.0.0.1 -p 8004 It takes 2 arguments -h for hostname and -p for port. PHP Code #!/usr/bin/php -q ?php // set a couple of things so we dont kill the system ob_implicit_flush(true); set_time_limit(30); // Open stdin so we can read the AGI data in $in = fopen(php://stdin, r); // Connect echo connect\n\n; // Answer echo sendmsg\n; echo call-command: execute\n; echo execute-app-name: answer\n\n; // Play a prompt echo sendmsg\n; echo call-command: execute\n; echo execute-app-name: playback\n; echo execute-app-arg: /usr/local/freeswitch/sounds/en/us/callie/ivr/8000/ivr- welcome_to_freeswitch.wav\n\n; // Wait sleep(5); // Hangup echo sendmsg\n; echo call-command: hangup\n\n; fclose($in); ? ivrd will call this script for each call. All itdoes is answer the channel tell FreeSWITCH to play the “welcome to freeswitch” prompt. Since the script is now controlling all call flow I needed to add a wait or it would send the hangup immediately before the prompt was played. Some improvements possible but that's 1 way to do it. It would be possible to do the socket directly in PHP but fs_ivrd is a nice option too. -- W ___ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org ___ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Re: [Freeswitch-users] Outbound socket PHP question
I wrote some notes on this but have yet to wiki it. example of an outbound socket connection where the call is answered, a variable is set then perhaps play one of the pre-installed files and hangup. ivrd fs_ivrd comes with freeswitch. It being a small daemon just invokes the script defined in a variable and passes data from it via STDIN/OUT Since this is an outbound socket connections it needs to be defined in the dialplan. Ex: extension name=outbound-socket condition field=destination_number expression=^55(522)$ action application=set data=ivr_path=/usr/local/freeswitch/scripts/ivrd-demo.php/ action application=socket data=127.0.0.1:8084 async full/ /condition /extension The above dialplan sample would invoke ivr-demo.php when 55522 is called as long as fs_ivrd is running. To start fs_ivrd: /usr/local/freeswitch/bin/fs_ivrd -h 127.0.0.1 -p 8004 It takes 2 arguments -h for hostname and -p for port. PHP Code #!/usr/bin/php -q ?php // set a couple of things so we dont kill the system ob_implicit_flush(true); set_time_limit(30); // Open stdin so we can read the AGI data in $in = fopen(php://stdin, r); // Connect echo connect\n\n; // Answer echo sendmsg\n; echo call-command: execute\n; echo execute-app-name: answer\n\n; // Play a prompt echo sendmsg\n; echo call-command: execute\n; echo execute-app-name: playback\n; echo execute-app-arg: /usr/local/freeswitch/sounds/en/us/callie/ivr/8000/ivr-welcome_to_freeswitch.wav\n\n; // Wait sleep(5); // Hangup echo sendmsg\n; echo call-command: hangup\n\n; fclose($in); ? ivrd will call this script for each call. All itdoes is answer the channel tell FreeSWITCH to play the “welcome to freeswitch” prompt. Since the script is now controlling all call flow I needed to add a wait or it would send the hangup immediately before the prompt was played. Some improvements possible but that's 1 way to do it. It would be possible to do the socket directly in PHP but fs_ivrd is a nice option too. -- W ___ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
[Freeswitch-users] Outbound socket question
Hi Guys, I'm going some work with outbound socket, and have a few questions. When each call is answered, I get a connection to my server socket. Is it right to assume that this connection will remain for the duration of the call? If so, do I still need to pass the UUID when I call an application such as playfile? Regards ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Re: [Freeswitch-users] Outbound socket question
yes the socket remains open the duration of your connection. and the uuid becomes optional at that point for sendmsg but may still come into play for some FSAPI based commands like uuid_getvar On Tue, Jun 2, 2009 at 12:04 PM, Nik Middleton nik.middle...@noblesolutions.co.uk wrote: Hi Guys, I’m going some work with outbound socket, and have a few questions. When each call is answered, I get a connection to my server socket. Is it right to assume that this connection will remain for the duration of the call? If so, do I still need to pass the UUID when I call an application such as playfile? Regards ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org -- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ AIM: anthm MSN:anthony_miness...@hotmail.com msn%3aanthony_miness...@hotmail.com GTALK/JABBER/PAYPAL:anthony.miness...@gmail.compaypal%3aanthony.miness...@gmail.com IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:8...@conference.freeswitch.org sip%3a...@conference.freeswitch.org iax:gu...@conference.freeswitch.org/888 googletalk:conf+...@conference.freeswitch.orggoogletalk%3aconf%2b...@conference.freeswitch.org pstn:213-799-1400 ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
[Freeswitch-users] Outbound socket
In my dialplan, I have set the following to send incoming calls to an application I am working on: action application=socket data=192.168.207.242:8084 async full/ This is working very nice, and I am receiving events for all incoming calls, and I am redirecting the calls in my application to some of the registered phones I have. But when I am terminating the calls, I do not getting the hangup events, which I would like to have so I can see when the calls were hung up. This is the last message I get: http://pastebin.freeswitch.org/4671 Do I have to set up an inbound socket to the FreeSwitch server, just to catch those messages too? Ivan ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Re: [Freeswitch-users] Outbound socket
What are you doing in your script over the socket? You're directing them elsewhere? /b On Jun 22, 2008, at 7:36 AM, Ivan C Myrvold wrote: In my dialplan, I have set the following to send incoming calls to an application I am working on: action application=socket data=192.168.207.242:8084 async full/ This is working very nice, and I am receiving events for all incoming calls, and I am redirecting the calls in my application to some of the registered phones I have. But when I am terminating the calls, I do not getting the hangup events, which I would like to have so I can see when the calls were hung up. This is the last message I get: http://pastebin.freeswitch.org/4671 Do I have to set up an inbound socket to the FreeSwitch server, just to catch those messages too? Ivan ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Re: [Freeswitch-users] Outbound socket
I do a sendmsg and execute a bridge sofia/ 192.168.207.203/116%192.168.207.203 Ivan Den 22. juni. 2008 kl. 14:40 skrev Brian West: What are you doing in your script over the socket? You're directing them elsewhere? /b On Jun 22, 2008, at 7:36 AM, Ivan C Myrvold wrote: In my dialplan, I have set the following to send incoming calls to an application I am working on: action application=socket data=192.168.207.242:8084 async full/ This is working very nice, and I am receiving events for all incoming calls, and I am redirecting the calls in my application to some of the registered phones I have. But when I am terminating the calls, I do not getting the hangup events, which I would like to have so I can see when the calls were hung up. This is the last message I get: http://pastebin.freeswitch.org/4671 Do I have to set up an inbound socket to the FreeSwitch server, just to catch those messages too? Ivan ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Re: [Freeswitch-users] Outbound socket
SendMsg call-command: execute execute-app-arg: sofia/192.168.207.203/116%192.168.207.203 execute-app-name: bridge Ivan Den 22. juni. 2008 kl. 14:40 skrev Brian West: What are you doing in your script over the socket? You're directing them elsewhere? /b On Jun 22, 2008, at 7:36 AM, Ivan C Myrvold wrote: In my dialplan, I have set the following to send incoming calls to an application I am working on: action application=socket data=192.168.207.242:8084 async full/ This is working very nice, and I am receiving events for all incoming calls, and I am redirecting the calls in my application to some of the registered phones I have. But when I am terminating the calls, I do not getting the hangup events, which I would like to have so I can see when the calls were hung up. This is the last message I get: http://pastebin.freeswitch.org/4671 Do I have to set up an inbound socket to the FreeSwitch server, just to catch those messages too? Ivan ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Re: [Freeswitch-users] Outbound socket
I see in the documentation that I should send a Sendmsg uuid, and not a SendMsg without the uuid. Maybe that will give me all messages with this uuid? Ivan Den 22. juni. 2008 kl. 14:59 skrev Ivan C Myrvold: SendMsg call-command: execute execute-app-arg: sofia/192.168.207.203/116%192.168.207.203 execute-app-name: bridge Ivan Den 22. juni. 2008 kl. 14:40 skrev Brian West: What are you doing in your script over the socket? You're directing them elsewhere? /b On Jun 22, 2008, at 7:36 AM, Ivan C Myrvold wrote: In my dialplan, I have set the following to send incoming calls to an application I am working on: action application=socket data=192.168.207.242:8084 async full/ This is working very nice, and I am receiving events for all incoming calls, and I am redirecting the calls in my application to some of the registered phones I have. But when I am terminating the calls, I do not getting the hangup events, which I would like to have so I can see when the calls were hung up. This is the last message I get: http://pastebin.freeswitch.org/4671 Do I have to set up an inbound socket to the FreeSwitch server, just to catch those messages too? Ivan ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Re: [Freeswitch-users] Outbound socket
I'm doing something similar and I don't see the HANGUP either. What I do see is that the control socket is closed when the hangup occurs, so I use that as a proxy for HANGUP. Not ideal but it works for me. ___ From: Ivan_C_Myrvold To: freeswitch-users@lists.freeswitch.org Sent: 06/22/2008 08:59 AM Received: 06/22/2008 09:00 AM Subject: Re: [Freeswitch-users] Outbound socket SendMsg call-command: execute execute-app-arg: sofia/192.168.207.203/116%192.168.207.203 execute-app-name: bridge Ivan Den 22. juni. 2008 kl. 14:40 skrev Brian West: What are you doing in your script over the socket? You're directing them elsewhere? /b On Jun 22, 2008, at 7:36 AM, Ivan C Myrvold wrote: In my dialplan, I have set the following to send incoming calls to an application I am working on: This is working very nice, and I am receiving events for all incoming calls, and I am redirecting the calls in my application to some of the registered phones I have. But when I am terminating the calls, I do not getting the hangup events, which I would like to have so I can see when the calls were hung up. This is the last message I get: http://pastebin.freeswitch.org/4671 Do I have to set up an inbound socket to the FreeSwitch server, just to catch those messages too? Ivan ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Re: [Freeswitch-users] Outbound socket
Good point. I'm using outbound sockets - so the UUID is implied. Seems to work well. I see the socket for the terminated call close; the others stay open. ___ From: Ivan_C_Myrvold To: freeswitch-users@lists.freeswitch.org CC: Greg_White Sent: 06/22/2008 09:39 AM Received: 06/22/2008 09:39 AM Subject: Re: [Freeswitch-users] Outbound socket That doesn't help if you have several calls going, and one of the hangs up. You don't know which of them hang up, if you doesn't see the hangup message with the uuid in it. Ivan Den 22. juni. 2008 kl. 15:03 skrev Greg White: I'm doing something similar and I don't see the HANGUP either. What I do see is that the control socket is closed when the hangup occurs, so I use that as a proxy for HANGUP. Not ideal but it works for me. ___ From: Ivan_C_Myrvold To: freeswitch-users@lists.freeswitch.org Sent: 06/22/2008 08:59 AM Received: 06/22/2008 09:00 AM Subject: Re: [Freeswitch-users] Outbound socket SendMsg call-command: execute execute-app-arg: sofia/192.168.207.203/116%192.168.207.203 execute-app-name: bridge Ivan Den 22. juni. 2008 kl. 14:40 skrev Brian West: What are you doing in your script over the socket? You're directing them elsewhere? /b On Jun 22, 2008, at 7:36 AM, Ivan C Myrvold wrote: In my dialplan, I have set the following to send incoming calls to an application I am working on: This is working very nice, and I am receiving events for all incoming calls, and I am redirecting the calls in my application to some of the registered phones I have. But when I am terminating the calls, I do not getting the hangup events, which I would like to have so I can see when the calls were hung up. This is the last message I get: http://pastebin.freeswitch.org/4671 Do I have to set up an inbound socket to the FreeSwitch server, just to catch those messages too? Ivan ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Re: [Freeswitch-users] Outbound socket
OK, I did it this way, too, after you gave me that idea. I will not catch the release cause, but at least now I get the hangup time. Thanks! Ivan Den 22. juni. 2008 kl. 15:55 skrev Greg White: Good point. I'm using outbound sockets - so the UUID is implied. Seems to work well. I see the socket for the terminated call close; the others stay open. From: Ivan C Myrvold To: freeswitch-users@lists.freeswitch.org CC: Greg White Sent: 06/22/2008 09:39 AM Received: 06/22/2008 09:39 AM Subject: Re: [Freeswitch-users] Outbound socket That doesn't help if you have several calls going, and one of the hangs up. You don't know which of them hang up, if you doesn't see the hangup message with the uuid in it. Ivan Den 22. juni. 2008 kl. 15:03 skrev Greg White: I'm doing something similar and I don't see the HANGUP either. What I do see is that the control socket is closed when the hangup occurs, so I use that as a proxy for HANGUP. Not ideal but it works for me. From: Ivan C Myrvold To: freeswitch-users@lists.freeswitch.org Sent: 06/22/2008 08:59 AM Received: 06/22/2008 09:00 AM Subject: Re: [Freeswitch-users] Outbound socket SendMsg call-command: execute execute-app-arg: sofia/192.168.207.203/116%192.168.207.203 execute-app-name: bridge Ivan Den 22. juni. 2008 kl. 14:40 skrev Brian West: What are you doing in your script over the socket? You're directing them elsewhere? /b On Jun 22, 2008, at 7:36 AM, Ivan C Myrvold wrote: In my dialplan, I have set the following to send incoming calls to an application I am working on: This is working very nice, and I am receiving events for all incoming calls, and I am redirecting the calls in my application to some of the registered phones I have. But when I am terminating the calls, I do not getting the hangup events, which I would like to have so I can see when the calls were hung up. This is the last message I get: http://pastebin.freeswitch.org/4671 Do I have to set up an inbound socket to the FreeSwitch server, just to catch those messages too? Ivan ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Re: [Freeswitch-users] Outbound socket
On outbound event socket SendMsg alone is fine. I'm pretty sure once you send the bridge message you're finished and your not going to get anything else. /b On Jun 22, 2008, at 8:05 AM, Ivan C Myrvold wrote: I see in the documentation that I should send a Sendmsg uuid, and not a SendMsg without the uuid. Maybe that will give me all messages with this uuid? Ivan ___ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org