func runEventHandler(s string, producer chan []byte) {
	var ariMessage string
	url := strings.Join([]string{config.WebsocketURL, "?app=", s, "&api_key=", config.WSUser, ":", config.WSPassword}, "")
	Info.Printf("Attempting to connect to ARI websocket at: %s", url)
	ws, err := websocket.Dial(url, "ari", config.Origin)
	if err != nil {
		log.Fatal(err)
	}
	Info.Printf("Starting producer loop for application %s", s)
	for {
		err = websocket.Message.Receive(ws, &ariMessage)  
		if err != nil {
			log.Fatal(err)
		}
		go PublishMessage(ariMessage, producer)  
	}
}
runEventHandler sets up a websocket connection to an ARI application.
package main
import (
	"bytes"
	"encoding/json"
	"flag"
	"github.com/nvisibleinc/go-ari-library"
	"golang.org/x/net/websocket"
	"io/ioutil"
	"log"
	"net/http"
	"os"
	"os/signal"
	"strings"
	"syscall"
	"time"
)
var (
	config         Config             
	client         = &http.Client{}   
	proxyInstances *proxyInstanceMap  
	Debug          *log.Logger
	Info           *log.Logger
	Warning        *log.Logger
	Error          *log.Logger
)
func signalCatcher() {
	ch := make(chan os.Signal)
	signal.Notify(ch, syscall.SIGINT)
	sig := <-ch
	log.Printf("Signal received: %v", sig)
	os.Exit(0)
}
func init() {
	var err error
	Debug = ari.InitLogger(os.Stdout, "DEBUG")
	Info = ari.InitLogger(os.Stdout, "INFO")
	Warning = ari.InitLogger(os.Stdout, "WARNING")
	Error = ari.InitLogger(os.Stderr, "ERROR")
	Info.Println("Loading configuration for proxy.")
	configpath := flag.String("config", "./config.json", "Path to config file")
	Debug.Println("Parsing the configuration file.")
	flag.Parse()
	Debug.Println("Reading in the configuration from the file.")
	configfile, err := ioutil.ReadFile(*configpath)
	if err != nil {
		Error.Fatal(err)
	}
	Debug.Println("Unmarshaling proxy configuration.")
	json.Unmarshal(configfile, &config)
	Debug.Println(&config)
	Debug.Println("Initialize the proxy instance map.")
	proxyInstances = NewproxyInstanceMap()  
}
func main() {
	Info.Println("Initializing the message bus.")
	ari.InitBus(config.MessageBus, config.BusConfig)
	for _, app := range config.Applications {
		Info.Printf("Initializing signalling bus for application %s", app)
		producer := ari.InitProducer(app)  
		Info.Printf("Starting event handler for application %s", app)
		go runEventHandler(app, producer)  
	}
	go signalCatcher()  
	select {}
}