Twisted features a decorator named inlineCallbacks which allows you to work with deferreds without writing callback functions.

This is done by writing your code as generators, which yield deferreds instead of attaching callbacks.

Consider the following function written in the traditional deferred style:

using inlineCallbacks, we can write this as:

from twisted.internet.defer import inlineCallbacks

Instead of calling addCallback on the deferred returned by redis.Connection, we yield it. this causes Twisted to return the deferred‘s result to us.

Though the inlineCallbacks looks like synchronous code, which blocks while waiting for the request to finish, each yield statement allows other code to run while waiting for the deferred being yielded to fire.

inlineCallbacks become even more powerful when dealing with complex control flow and error handling.


WebRTC provides Real-Time Communications directly from better web browsers and devices without requiring plug-ins such as Adobe Flash nor Silverlight.

FreeSWITCH is a WebRTC gateway because it’s able to accept encrypted media from browsers, convert it, and exchange it with other communication networks  that use different codecs and encryptions, for example, PSTN, mobile carriers, legacy systems, and others. FreeSWITCH can be a gateway between your SIP network and applications and billions of browsers on desktops, tablets, and smartphones.

Configuration :

Look for the following in sofia profile and uncomment them:

Clients :

How it works :

By default, Sofia will listen on port 7443 for WSS clients. You may want to change this port if you need your clients to traverse very restrictive firewalls. Edit /usr/local/freeswitch/conf/sip-profiles/internal.xml and change the “wss-binding” value to 443. This number, 443, is the HTTPS (SSL) port, and is almost universally open in all firewalls.Remember that if you use port 443 for WSS, you cannot use that same port for HTTPS, so you will need to deploy your secure web server on another machine.

Example :

SIP signaling in JavaScript with SIP.js (WebRTC client)

Let’s carry out the most basic interaction with a web browser audio/video through WebRTC. We’ll start using SIP.js.

A web page will display a click-to-call button, and anyone can click. That call will be answered by our company’s PBX and routed to our employee extension (1000). Our employee will wait on a browser with the “answer” web page open, and will automatically be connected to the incoming call.

call.html :

call.js :

answer.html :

answer.js :

How it works :

Our employee (the callee, or the person who will answer the call) will sit tight with the answer.html web page open on their browser.

Our customer (the caller, or the person who initiates the communication) will visit the call.html webpage and then click on the Start Call button. This clicking will activate the JavaScript that creates the communication session using the invite method of the user agent, passing as an argument the SIP address of our employee.

use this to see if ws and wss work :

How Implement Multiservice in Twisted.

Multiservice module is service collection provided by twisted, which is useful for creating a new service and combines with two or more existing services.

The major tools that manages Twisted application is a command line utility called twistd. twistd is a cross-platform, and is the recommended tool for running twisted applications.

The core component of the Twisted Application infrastructure is the

object. which represents your application. Application acts as a container of any “Services” that your application provides. This will be done through Services.

Services manages application that can be started and stopped. In Application object can contain many services, or can even hierarchies of Services using “Multiservice” or your own custom IServiceCollection implementations.

Multiservice Implementaion:

To use multiserivce, which implements IService. For this, import internet and service module.


Example :

To run, Save above code in a file as serviceexample.tac . Here, “tac ” file is regular python file. Twisted application infrastructure, protocol implementations live in a module, services, using those protocols are registered in a Twisted Application Configuration(TAC) file and the reactor and configuration are managed by an external utility.

Here, I use multiservice functionality from service. agentservice create object of multiservice. Then add services using add service method. In service, you can add web servers, FTP servers and SSH clients. After this, set application name and pass application to serviceparent method.

now, add service on port 8082 as :

add another service same as above on port 8083 as:

To run serviceexample.tac file using twistd program, use command twistd -y serviceexample.tac -n. After this, open browser and enter url localhost:8082 and localhost:8083. You can see result on web page and both TCP servers are active.

Email template

Coding HTML for email can be tough. If you included video, flash, javascript or image chances it won’t show up you wanted it to.

You may have had some issues with your in email clients like Gmail or Apple Mail and Outlook.

Some comman problems are :-

  • Some email client not supported all CSS
  • Syntax improperly in tables or missing tags
  • Fonts are not displaying correctly

Troubleshoot your problem :-

If you’re having issues with columns, or rows not appearing in a table, add a border to the table to identify problems and better visualize the table structure.

If you’re seeing centered text when you prefer it left-aligned, make sure you’ve included properties like valign and align in <td> cells and <p> tags.

You may have some issues with your HTML emails looking great in email clients like Gmail or Apple Mail but rendering poorly in Outlook.

Outlook does not support many features :-

  • Animated GIF.
  • Background Images.
  • Padding for <div>, <p>, and <a> tags. Outlook ignores it. Use hspace or vspace attributes on images or tables to format your content.
  • Width for <div> and <p> tags. Outlook ignores it. Use hspace or vspace attributes on images or tables to format your content.

Email Client CSS Support:-

Open below link and check which CSS support in browser, desktop and mobile in various email client’s like outlook, yahoo, gmail.

Web-based call control with mod_httapi

The mod_httapi module was built to allow you to make your call control and IVRs dynamic. With it you can generate custom IVRs based on user input. Freeswitch mod_httapi is a simple HTTP POST operation to send various bits of information to a web application for restful way to control freeswitch call flows.

This module provides an HTTP based Telephony API using a standard FreeSWITCH application interface as well as a cached http file format interface.

HTTAPI syntax :-

mod_httapi configuration file :-

The mod_httapi configuration file is found in conf/autoload_configs and is named httapi.conf.xml . It contains several settings parameters as well as a profiles section. The example configuration contains a default HTTAPI profile or you may create your own profiles.

Inside the profile tag you will notice a number of param entries. These control things such as default settings for various work actions, permissions control (see the following sections), and the default URL to use for HTTP requests.

Example :-

Example :-

You don’t need to answer the call in the dialplan before calling into httapi Both extensions below will make httapi requests to my application:

Below example call from web :-

In above example if call is successfully bridge than it give response like :

Permissions :-
With all the control that you have in httapi , sometimes it becomes necessary to little bit with permissions on things such as variables that shouldn’t be changed, or applications and APIs that you don’t want to execute. Permissions tag you’ll find many different permissions that you can enable, with even more fine-grained control over certain aspects of some of them.

Reference link :-

How to sync time on linux server using Network Time Protocol (NTP)

Some times we might wrong time on servers or on your machine. On machines cmos battery is helpful to keep system time update to date even machine is not running. If this is not working or for some reason we might get wrong time on machines some times. To make sure servers time is update it is recommended to configure your system with NTP servers to sync server time.

NTP is the protocol which is used to sync system time. which stands for Network Time protocol. System will sync time form any one of the NTP server available using this protocol

We use the program ntp on linux to sync time from NTP servers. If you don’t this thing already installed, install using following instructions.


sudo apt-get install ntp 

apt-get install ntpdate

CentOS or Redhat

sudo yum install ntp

Once this program is installed, you will get /etc/ntp.conf  file. This file can be edited to configure ntp. You can place your desired NTP server in this file to sync time from that server. List of NTP servers can be found at NTP Servers

After you install package ntp you will get several commands including ntpd deamon. This daemon will run in background to sync system time.

Start nptd deamon

/etc/init.d/ntpd start

Configure ntpd to run as startup

chkconfig ntpd on 

Update time using ntpdate

If not already installed

Update system time




Domain Registry vs Registrar vs Registrant

There are three different roles involved in domain name registration and management. That is, the registry, registrar, and registrant. The following information will explain these roles and how they work.


A domain name registry is an organization that manages top-level domain names. They create domain name extensions, set the rules for that domain name, and work with registrars to sell domain names to the public. For example, VeriSign manages the registration of .com domain names and their domain name system (DNS).

In short, registry maintains an authoritative database regarding top level or lower level domains including zone files.

Few registries who manages popular top level domains,



The registrar is an (ICANN)accredited organization, that sells domain names to the public, that is registrants like you. That is, registrar works with registry to sell domains to public.

Few popular registrars are,


A registrant is the person or organization or company who registers a domain name. Registrants can manage their domain name’s settings through their registrar. When changes are made to the domain, registrar will send the information to the registry to be updated and saved in the registry’s database. You become a registrant if you are registering domain name!

Registry Registrar and Registrant Hierarchy Illustrated
Registry Registrar and Registrant Hierarchy Illustrated

You can find registry details of domains at root registry database






List of AWS regions and availability zones

List of  AWS Regions

This is complete list of  AWS regions available currently.

S.No Code Name
1 us-east-1 US East (N. Virginia)
2 us-west-2 US West (Oregon)
3 us-west-1 US West (N. California)
4 eu-west-1 EU (Ireland)
5 eu-central-1 EU (Frankfurt)
6 ap-southeast-1 Asia Pacific (Singapore)
7 ap-northeast-1 Asia Pacific (Tokyo)
8 ap-southeast-2 Asia Pacific (Sydney)
9 ap-northeast-2 Asia Pacific (Seoul)
10 sa-east-1 South America (São Paulo)
11 cn-north-1 China (Beijing)
12 ap-south-1 India (Mumbai)

AWS upcoming regions


S.No Code Name
3 N/A UK

List of  AWS regions and their availability zones

S.No AWS region code AWS region name Number Of Availability Zones Availability Zone Names
1 us-east-1 Virginia 4 us-east-1a
2 us-west-2 Oregon 3 us-west-2a
3 us-west-1 N. California 3 us-west-1a
4 eu-west-1 Ireland 3 eu-west-1a
5 eu-central-1 Frankfurt 2 eu-central-1a
6 ap-southeast-1 Singapore 2 ap-southeast-1a
7 ap-southeast-2 Sydney 3 ap-southeast-2a
8 ap-northeast-1 Tokyo 2 ap-northeast-1a
9 ap-northeast-2 Seoul N/A N/A
10 sa-east-1 Sao Paulo 3 sa-east-1a
11 cn-north-1 China (Beijing) N/A N/A
12 ap-south-1 India (Mumbai) 2 ap-south-1a

If you are familiar with AWS CLI you can always check regions and availability zones using following aws cli commands

Find regions using AWS CLI

Command:  aws ec2 describe-regions


Find AWS availability zones using AWS CLI

You can find the availability zones of particular region using following command

There are other two commands ec2-describe-regions and ec2-describe-availability-zone which are also helpful to retrieve regions and availability zones respectively. These are available in the package ec2-api-tools

You can check the availability zones of your current region in AWS console in the dashboard under service health, under availability zones


AWS Regions  google map

Find AWS Regions location here in google map (under development). You are invited to improve.



Note: AWS frequently updates availability zones and regions. Please consider also checking zones on aws console. 




How to list IP addresses of all connected machines in local network

If you want to list valid connected IPs in your local network, you can do it by logging into your router if you have a password, else you can check  connected client IPs command line  using either of the following two commands.


Let’s see, how you can list connected systems IPs in your netowrk using these commands

List IPs using command namp

Basically this command namp is used to scan networks. It is most widely  used as port scanner. You can do many things with this command.

Auditing the security of a device or firewall by identifying the network

Identifying open ports on a target host

Network i maintenance and asset management.

Generating traffic to hosts on a network, response analysis and response time measurement.

Find and exploit vulnerabilities in a network

Ok, lets come to main thing listing IPs of connected systems in network

nmap -sP 192.168.1.*

Where,  you have to specify the IP range or subnet to scan to get the list of connected hosts. Options -sP  no port scan based on your version you can also use option -sn .

Warning:  Do not performs scans on a network without proper authorization.

List IPs using command arp

Basically arp is the protocol which stands for Address Resolution Protocol. Many linux boxes are loaded with command arp

Ping your network using a broadcast address i.e. “ping” if your IP is or something in same network. After that, perform “arp -a” to determine all the computing devices connected to the network

Note: You can find your broadcast IP in ifconfig output for corresponding network interface

You can use the following command to list connected clients after you ping your broadcast IP,

arp -a

This command will list most of the IPs found but it’s not that much accurate. Some times routers hide machines which are connected via wire to the machines which are connected via wifi network.