This example you mention handles an outbound connection coming FROM FreeSWITCH server. What this means is that your application is *NOT* the one that connects to FreeSWITCH, but acts as a server waiting for connections coming from FreeSWITCH. When a call is received on FreeSWITCH, it will open a socket connection to your application and you'll have total control of the call. Please take a couple of minutes and read the wiki page where this is explained: http://wiki.freeswitch.org/wiki/Java_ESL_Client#Outbound_socket_client_usage In outbound mode, your code will be executed for every incoming call. If you want to use FreeSWITCH out of the context of an incoming call (like to originate new calls) then you must use it in inbound mode (see http://wiki.freeswitch.org/wiki/Java_ESL_Client#Inbound_client_usage). The library contains a very good set of unit tests (ClientTest.java) showing how to use it in inbound mode. From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Marwan Idriss Sent: Wednesday, April 10, 2013 3:08 AM To: freeswitch-users@lists.freeswitch.org Subject: [Freeswitch-users] http://wiki.freeswitch.org/wiki/Java_ESL_Client, how I can make a connection before starting to handle Outbound connection ? Greeting, bellow is an example to handle outbound connection and make hung up: but it never show How to make the connection in first place is their an example in main of how this function work ? /* * Copyright 2010 david varnes. * * Licensed under the Apache License, version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.freeswitch.esl.client.outbound.example; import org.freeswitch.esl.client.outbound.AbstractOutboundClientHandler; import org.freeswitch.esl.client.transport.SendMsg; import org.freeswitch.esl.client.transport.event.EslEvent; import org.freeswitch.esl.client.transport.message.EslMessage; import org.freeswitch.esl.client.transport.message.EslHeaders.Name<http://org.freeswitch.esl.client.transport.message.EslHeaders.Name>; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; /** * Simple example of a handler for outbound connection from FreeSWITCH server. * This class will log some of the FreeSWTICH call channel variables and * then hangup the call. * * @author david varnes */ public class SimpleHangupOutboundHandler extends AbstractOutboundClientHandler { @Override protected void handleConnectResponse( ChannelHandlerContext ctx, EslEvent event ) { log.info<http://log.info>( "Received connect response [{}]", event ); if ( event.getEventName().equalsIgnoreCase( "CHANNEL_DATA" ) ) { // this is the response to the initial connect log.info<http://log.info>( "======================= incoming channel data =============================" ); log.info<http://log.info>( "Event-Date-Local: [{}]", event.getEventDateLocal() ); log.info<http://log.info>( "Unique-ID: [{}]", event.getEventHeaders().get( "Unique-ID" ) ); log.info<http://log.info>( "Channel-ANI: [{}]", event.getEventHeaders().get( "Channel-ANI" ) ); log.info<http://log.info>( "Answer-State: [{}]", event.getEventHeaders().get( "Answer-State" ) ); log.info<http://log.info>( "Caller-Destination-Number: [{}]", event.getEventHeaders().get( "Caller-Destination-Number" ) ); log.info<http://log.info>( "======================= = = = = = = = = = = = =============================" ); // now hangup the call hangupCall( ctx.getChannel() ); } else { throw new IllegalStateException( "Unexpected event after connect: [" + event.getEventName() + ']' ); } } @Override protected void handleEslEvent( ChannelHandlerContext ctx, EslEvent event ) { log.info<http://log.info>( "Received event [{}]", event ); } private void hangupCall( Channel channel ) { SendMsg hangupMsg = new SendMsg(); hangupMsg.addCallCommand( "execute" ); hangupMsg.addExecuteAppName( "hangup" ); EslMessage response = sendSyncMultiLineCommand( channel, hangupMsg.getMsgLines() ); if ( response.getHeaderValue( Name.REPLY_TEXT ).startsWith( "+OK" ) ) { log.info<http://log.info>( "Call hangup successful" ); } else { log.error( "Call hangup failed: [{}}", response.getHeaderValue( Name.REPLY_TEXT ) ); } } }