MHSpot.com
SipToSis TM - Skype Asterisk/FreePBX/trixbox/Elastix Trunks on Linux or Windows - Asterisk Skype Trunk Setup
STS Home Appicus FAQ ATA Setup Skype Trunk Setup Troubleshooting Forum Downloads
You are expected to already know how to install software on your platform and how to configure Asterisk/FreePBX/trixbox/Elastix/PBX-in-a-flash peers, extensions and routes. When configured correctly, you will have multiple channel inbound and outbound Skype calling abilities integrated into your Asterisk/FreePBX/trixbox/Elastix/PBX-in-a-flash server. You can install everything on the same box if you desire.


Here are some Linux instructions for those who need a little extra help.

Install the applications
Install Asterisk, PBX-in-a-Flash, trixbox, Elastix or other SIP PBX.
Some tutorials are here: PBX-in-a-Flash without tears Elastix without tears trixbox without tears



Install Sun/Oracle's Java 1.5 JRE or higher (Linux Users - Do NOT use openjdk).
Download Skype client, install and create skype accounts for as many Skype channels as you need. Note: You can use a single Skype account if you are going to use stsProxy or make outgoing calls only.
SipToSis must be run on the same computer as the Skype client.
Download the latest SipToSis SIP Skype Bridge and extract into a new folder 'siptosis'.
Download the latest SipToSis Skype Trunk Builder for your platform and extract into a new folder 'stsTrunkConfig'.
Make sure to keep the folder/path structure contained in the archives.
For linux only, install Xvfb if you don't already have it installed. (Example: yum install xorg-x11-server-Xvfb or sudo apt-get install Xvfb) - Some sort of X server is required.

Configure a functional test channel first.
It will be easier to correct a problem with a single channel. On linux: If you plan on using snd-dummy, test it thoroughly on this test channel.
Basic SipToSis setup is similiar to a SIP device - see the SipToSis ATA Setup Guide for initial setup.

This setup is expecting that you register SipToSis with the PBX.
Look for #Sample Asterisk registration example section in siptosis.cfg.

In addition to the registration, here are some recommended changes to make in siptosis.cfg for a PBX (Single or Multi channel).
  • concurrentcalllimit=1
  • is_registrar=no
  • autoCleanTasks=cleanCallHistory,cleanChatHistory,cleanVoicemailHistory,cleanFriends (Requires 20110331+)
Below is a simple test Asterisk peer/extension setup. You need to set the desired context and set the registration info and IP address to match your SipToSis config.
For plain Asterisk:
Add to sip.conf
[skypetestuser]
username=skypetestuser  ; use same as in brackets above
type=friend
context=default ; correct as needed by your setup
secret=siptosisregpassword
host=dynamic ; if not dynamic, you will need to set port also
nat=no
dtmfmode=auto
canreinvite=no ; possibly set to yes if you know what you are doing
qualify=yes ; optional
defaultip=siptosisip ; optional - fix the ip if used
incominglimit=1
outgoinglimit=1
call-limit=1
busylevel=1

Add to extensions.conf: 
exten => _7.,1,Dial(SIP/skypetestuser/${EXTEN:1})
;you would then dial 7 and the number you want to call
For FreePBX and variants (PBXinaflash/trixbox/Elastix): Screen shots
Create a SIP trunk:
	Maximum Channels: 1
	Dial Rules: .         
	Trunk Name: skypetestuser
	Peer Details:
	  username=skypetestuser
	  type=friend
	  secret=siptosisregpassword
	  context=from-trunk
	  host=dynamic ; if not dynamic, you will need to set port also
	  nat=no
	  dtmfmode=auto
	  canreinvite=no ;(possibly set to yes if you know what you are doing)
	  qualify=yes ; optional
	  incominglimit=1
	  outgoinglimit=1
	  call-limit=1
	  busylevel=1

Create an Outbound Route:
   Dial Patterns: 7|.
    Trunk Sequence: 
                  0 SIP/skypetestuser - click Add
	Submit, Apply configuration changes.

Dial 7 and anything else from an extension and it calls out via the trunk.

For incoming calls, you should create a catch all inbound route and/or ring group. See screen shots Screen shots for example.
Dialing Note: Normal Asterisk PBX's can strip the prefix in extensions.conf file like this:
exten => _7X.,1,Dial(SIP/skypetestuser/${EXTEN:1}) or exten => _901.,n,Dial(SIP/skypetestuser/${EXTEN:3})
If your PBX can't be configured this way, then you can work around the PBX limitation by adding entries to SkypeOutDialingRules.props like this:
If your PBX dialing prefix is 7 you could add the following line:
^7([1-9][0-9]{10})$:+$1
The $1 will only capture what's in the parenthesis. In the example above, the 7 will be left out when making the SkypeOut call with 11 digit dialing. If 713051234567 was sent to the gateway, SipToSis would transform it to +13051234567. For other prefixes, change the 7 to the new prefix. Tip: make sure no other rules make the same match. Read up on regular expressions if you need to get more complicated.

After you have tested your single channel test configuration completely you are ready to build the multi channel trunk.
Scroll down to the Linux section or for Windows click here.


Linux Skype Asterisk/FreePbx/PBX-in-a-flash/trixbox/Elastix Trunk with SipToSis and the latest stsTrunkBuilder.


The generated scripts were tested on CentOS 5.2/5.3/5.4 and Ubuntu 9.04/10.04 using Xvfb (X Virtual Frame Buffer) to create X sessions. You can change it to use vnc and whatever X window manager you want (twm, ratpoison, etc.)

Initialize the stsTrunkBuilder
From the stsTrunkConfig folder, run chmod +x trunkConfig_linux to grant run permission.
Run ./trunkConfig_linux. Read and accept the license agreement. The configuration files will be installed.

Create the Asterisk Skype Trunk Channel Configurations
In stsTrunkConfig do this:
Edit stsTrunkDef.cfg and set parameters. Do not use the default passwordSeed.
Note: If using the clone options (Available with 20100408+) and same Skype User Id for all channels set cloneSource and cloneOverwrite
Note: If you plan on using the same Skype User Id for incoming calls, you will also need to setup stsProxy.
Add the skype user ids to use - Note: For multiple channels with the same Skype user, set them all the same and setup stsProxy so incoming calls will work.
Edit stsTrunkPbxSipBase.conf - Make any needed changes.
Edit stsTrunkPbxExtBase.conf - Make any needed changes.

Add your custom startup commands to stsControlBase if any
The generator does replacements of certain keywords contained in these files (not case sensitive).

  • osUserBase - replaced by osUserBase set in stsTrunkDef.cfg
  • stsTrunkPrefix - replaced with trunkname set in stsTrunkDef.cfg
  • stsPath - replaced with path to siptosis set in stsTrunkDef.cfg - extracted from stsBaseConfigFile setting

Prior to trunk builder 20100227 you will have to add a path to /sbin on CentOS so the script can find the lsmod command.
gedit (or vi) stsControlBase
export PATH=$PATH:/sbin

X Display methods:
I recommend the Xvfb method and is the default method in the control script.
Xvfb: (recommended)
You should not need to change the script to use Xvfb. You do need to install the required Xlibs and Xvfb to support Xvfb (This depends on your specific linux distribution). The X displays are already restricted to localhost using the default setup.
VNC:
Note: I did not have time to perform more than basic testing with vnc and is intentionally restricted to localhost. Change my vncserver settings in stsControlBase as needed. To enable vncserver method with twm do the following:
Edit stsControlBase and set displayMethod=VNC and also testtwmconfig=Y
Edit /etc/X11/twm/system.twmrc - add RandomPlacement above NoGrabServer line.

Sound Device:
With Sound hardware:
Look at the supplied sndShare_ALSA file for instructions or click Sharing sound device with Alsa.
It seems that PBX-in-a-Flash already shares the sound device!
No Sound hardware:
On a system without a sound card, you are forced to use the Alsa snd-dummy module. There have been many issues with this solution. You may or may not be successful with this option. Hopefully you already tested snd-dummy with your test channel.

Generate the trunk scripts
Run ./trunkConfig_linux - This will generate configuration files for each channel.
The test channel you created earlier will be used as a configuration base for all the skype trunk channels.
The password for each channel will be generated automatically.
All the scripts will be written to the directory specified by stsBaseConfigFile in stsTrunkDef.cfg.
If you used another configuration file name than the default, you can specify it as argument like this:
./trunkConfig_linux customTrunkDef.cfg
You can always rerun the trunk generator if you decide to make changes.
*** Note: A re-run will overwrite the files it already generated. ***

Run the patch command (not needed if cloning) (20100402+ stsTrunkBuilder versions)
./trunkConfig_linux patch
This will modify the skype config files for proper operation for incoming calls and some other common settings.
You can tweak the settings yourself in the stsTrunkDef.cfg.
For the config.xml file, modify the settings patchConfigRegex and patchConfigReplace
and for the shared.xml file modify patchSharedRegex and patchSharedReplace
If you add more channels later, you can run the patch again.

Add the Asterisk Skype trunk channel information to Asterisk
Plain Asterisk:
Add the generated skype trunk peer information from stsTrunkPbxSipMod.conf to your Asterisk sip.conf and the stsTrunkPbxExtMod.conf entries to Asterisk extensions.conf.
Add macro-stsdialresult (located in the SipToSis project) to extensions.conf. Note: I no longer use the the stsdialresults macro - use stsProxy instead.

For FreePBX:
Create a SIP Trunk for each channel as described earlier using the corresponding peer details from stsTrunkPbxSipMod.conf.

 Create an Outbound Route:
   Dial Patterns: 7|.
   Trunk Sequence: 
                 0 SIP/stsTrunk_01 - click Add
                 1 SIP/stsTrunk_02 - click Add
                 2 SIP/stsTrunk_03 - click Add
                 3 SIP/stsTrunk_04 - click Add
                 etc.
   Submit, Apply configuration changes.
Change 7 above to your desired dialing prefix.

Configure the Skype instances for operation
From the siptosis folder, grant run permission to the control script - once only. (chmod +x stsTrunk_Control)
Note: Make sure there are no instances of Skype running before performing this procedure.
Follow these steps to perform skype configuration for each channel:
Note: If using the clone options (Available with 20100408+) you should at least check a couple of channels
./stsTrunk_Control config xx (Change xx to the specific 2 digit trunk channel number)
Note: SipToSis will sit at 'initSkype' or display 'retrying every 5 seconds' until Skype is authorized and comes online.
Don't forget to check the 'login automatically' checkbox when logging in to skype!!!
Authorize SipToSis/skype4java to connect when that comes up and check the remember box.
Setup sound, turn off automatic updates and whatever else you need.
./stsTrunk_Control stop xx (Change xx to the channel number you just configured) (Note: If skype has a problem retaining settings, close it down using it's GUI.)
Do this procedure for every channel.

Starting the Skype Asterisk trunk.
To launch an individual channel, run ./stsTrunk_Control start xx (Change xx to the specific 2 digit trunk channel number) You should not see Skype or SipToSis on the display.
To bring up all the trunk channels run ./stsTrunk_Control start
This should launch the Xvfb, Skype and SipToSis instances for all channels.
You can verify SipToSis connection by looking at the SipToSis logs or by checking that the peers/trunks are online in Asterisk.

Stopping the Asterisk Skype trunk.
To stop an individual channel, run ./stsTrunk_Control stop xx (Change xx to the specific 2 digit trunk channel number)
To stop all the skype trunk channels, run ./stsTrunk_Control stop
This should stop all the Xvfb (or VNC), Skype and SipToSis processes.

You can see the running processes by running ./stsTrunk_Control status or ./stsTrunk_Control status xx (Change xx to the specific 2 digit trunk channel number)
You can also take screenshots of the Xvfb window as a diagnostic aid like this: ./stsTrunk_Control snapscreen xx (Change xx to the specific 2 digit channel number)

Making it start automatically at boot
edit /etc/rc.local (sudo vi /etc/rc.local)
Add this: su -l SipToSisOsUser -c "/home/SipToSisUser/SipToSis/stsTrunk_Control boot" before exit 0
Change 'SipToSisOsUser' to the actual os user name and 'SipToSis' to the actual folder name.
Note: if using snd-dummy, make sure modprobe is before siptosis startup command.
If sound device is not found only at boot time, add user to audio group: /etc/group
Example: audio:blahblah:pulse,someuser or adduser username audio
If the sound errors about hdmi etc. from skype bug you, edit /usr/share/alsa/alsa.conf (backup first) and comment out:
/usr/share/alsa/pulse.conf
/usr/share/alsa/bluetooth.conf
pcm.hdmi cards.pcm.hdmi
If you have trouble with the boot process, numerous diagnostic files get stored in siptosis/log at boot time.
NO, Skype and SipToSis are NOT required to run under root.



That's it. I hope you got it working, if not the SipToSis Skype Gateway Troubleshooting may offer some additional help. If you get stuck, leave a comment on the SipToSis Skype Gateway Forum and I will try to help you. I do not have the time to test every OS, Asterisk flavor or PBX. If you find an error/problem please post the correction to the Forum.



Windows Skype Asterisk Trunking with SipToSis and the latest stsTrunkBuilder.


It was tested on Windows XP Pro 32 bit and Vista 64 bit. Windows 2000 forward should work.

Initialize the stsTrunkBuilder
From the stsTrunkConfig folder, run trunkConfig_win.bat. Read and accept the license agreement. The configuration files will be installed.

Build the Asterisk to Skype Trunk Configuration
In the stsTrunkConfig folder do this:
Edit stsTrunkDef.cfg and set parameters. Do not use the default passwordSeed.
Add the skype user ids to use - Note: For multiple channels with the same Skype user, set them all the same and setup Appicus and stsProxy.
Note: If using the clone options (Available with 20100408+) and same Skype User Id for all channels set cloneSource and cloneOverwrite
Note: If you plan on using the same Skype User Id for incoming calls, you will also need to setup stsProxy.
Note: If you are going to use Appicus, install it first.
Edit stsTrunkPbxSipBase.conf - Make any changes specific to your needs.
Edit stsTrunkPbxExtBase.conf - Make any changes specific to your needs.
Run trunkConfig_win.bat - This will generate the needed files for each channel.
The test configuration you created earlier will be used as a base for all the trunk channels.
The password for each channel is generated automatically.
All the scripts are written to the folder specified by stsBaseConfigFile in stsTrunkDef.cfg.
If you used a different definition file name than the default, you can specify it as argument like this:
trunkConfig_win.bat customTrunkDef.cfg
You can always rerun the generator if you decide to make changes.
*** Note: Rerunning the generator will write over the files it already created. ***

Run the patch command (not needed if cloning) (20100408+ stsTrunkBuilder versions)
trunkConfig_win.bat patch
This will modify the skype config files for proper operation for incoming calls and some other common settings.
You can tweak the settings yourself in the stsTrunkDef.cfg.
For the config.xml file, modify the settings patchConfigRegex and patchConfigReplace
and for the shared.xml file modify patchSharedRegex and patchSharedReplace
If you add more channels later, you can run the patch again.

If using RunAs option (not recommended), create a windows account for each channel.
After you create the account, login to each windows account and click the skype icon.
Login to the skype account you already created.
Setup all your skype preferences.
Make some test calls to make sure it works.
Exit the skype program.
Switch back to the master admin user.

Add the configuration information to Asterisk
Add the generated skype trunk information from stsTrunkPbxSipMod.conf and stsTrunkPbxExtMod.conf to your Asterisk sip.conf and extensions.conf files.
Add macro-stsdialresult (located in the SipToSis project) to extensions.conf. Note: I no longer use the the stsdialresults macro - use stsProxy instead.

Starting it all up (Each channel is a different Skype Account)
To start an individual channel, run stsTrunk_xx_start.bat (Change xx to the specific 2 digit trunk channel number)
To start all the channels, run stsTrunkStartAll_win.bat
This should startup all the Skype instances and also the SipToSis instances.
Note: SipToSis will wait at initSkype or display 'retrying every 5 seconds' until Skype comes online.
Note: If using RunAs option, the password for each login will be prompted for by the operating system the first time that login is used. There is a security issue with using /savecred and RunAs - if you are worried, remove the /savecred option. You will then be prompted for the passwords every time the trunk channels are started/stopped. I do not recommend using the RunAs option.

Starting it all up (Each channel is the same Skype Account)
In this configuration it is not possible to start all the channels properly via the stsTrunkStartAll_win.bat batch file. You should have already installed Appicus.
You need to perform an initialization procedure before attempting to startup using the Appicus service.
Run each stsTrunk_xx_start.bat and grant API authorization. (Change xx to the specific 2 digit trunk channel number) Make sure to shutdown each channel before starting the next. When the procedure has been completed, all channels can be started by starting the Appicus service.
This should startup all the Skype instances and also the SipToSis instances (and optionally stsProxy). You can confirm proper startup by looking at the siptosis/log files for each channel. If there are no logs, check the Appicus logs for startup errors.

Shutting down the Skype to Asterisk trunk channels. (Not using Appicus)
To stop an individual channel, run stsTrunk_xx_stop.bat (Change xx to the specific 2 digit trunk channel number)
To stop all the channels, run stsTrunkStopAll_win.bat
This should halt all the Skype instances and also the SipToSis instances.
Note: Shutdown will leave the skype icon on the taskbar - just hover over it to make it go away.

Shutting down the Skype to Asterisk trunk channels. (With Appicus)
Simply stop the appicus_sts service to shutdown all processes.

Automatic startup
The easiest way is to use the Appicus Windows Service Wrapper (required when using the same Skype Account).
If you don't mind setting up an automatic login, you can add 'stsTrunkStartAll_win.bat' to the windows startup (assuming separate Skype Accounts).

That's it. I hope you got it working, if not the SipToSis Skype Gateway Troubleshooting may offer some additional help. If you get stuck, leave a comment on the SipToSis Skype Gateway Forum and I will try to help you. I do not have the time to test every OS, Asterisk flavor or PBX. If you find an error/problem please post the correction to the Forum.