FreeSWITCH Event Socket library for the Go programming language.

Overview

eventsocket

FreeSWITCH Event Socket library for the Go programming language.

It supports both inbound and outbound event socket connections, acting either as a client connecting to FreeSWITCH or as a server accepting connections from FreeSWITCH to control calls.

This code has not been tested in production and is considered alpha. Use at your own risk.

Installing

Make sure $GOPATH is set, and use the following command to install:

go get github.com/fiorix/go-eventsocket/eventsocket

The library is currently a single file, so feel free to drop into any project without bothering to install.

Usage

There are simple and clear examples of usage under the examples directory. A client that connects to FreeSWITCH and originate a call, pointing to an Event Socket server, which answers the call and instructs FreeSWITCH to play an audio file.

Issues
  • timeout for response waiting

    timeout for response waiting

    I noticed under certain network conditions another source of goroutines remaining blocked forever :

    goroutine profile: total 240
    195 @ 0x42e19a 0x43d594 0x43c1fc 0x8382f4 0x8a9bf7 0x8ba614 0x45b261
    #	0x8382f3	github.com/fiorix/go-eventsocket/eventsocket.(*Connection).Send+0x283		github.com/fiorix/go-eventsocket/eventsocket/eventsocket.go:335
    

    so I added a 60 second timeout on waiting for the responses from fs

    opened by rif 4
  • server.go quit automaticly.

    server.go quit automaticly.

    I user server.go example file, but when hungup a call, the program exit with this log:

    New event Content-Disposition: "disconnect" Content-Length: "67" Content-Type: "text/disconnect-notice" Controlled-Session-Uuid: "34d4e991-50c8-4ad2-8a18-4b0fc573d1ba" BODY: "Disconnected, goodbye.\nSee you at ClueCon! http://www.cluecon.com/\n" 2015/01/07 14:05:48 EOF exit status 1

    How can I keep it alive as a daemon?

    opened by transtone 4
  • Phone doesn't hangup when call is hung up

    Phone doesn't hangup when call is hung up

    After the event socket is done completing, the phone remains connected and show calls shows the call still in progress. Executing hangup does not help.

    opened by mattwilliamson 3
  • uuid_break return error

    uuid_break return error "no reply"

    env: go 1.11 fs 1.8.2

    Code:

    ...
    if _, err = conn.Send("api uuid_break " + uuid); err != nil { // uuid is origination_uuid
    	sugar.Panicf("Got error while executing playback: %s", err)
    }
    

    get error:

    panic: Got error while executing playback: no reply
    
    opened by meilihao 2
  • Shouldn't Get() capitalize the key?

    Shouldn't Get() capitalize the key?

    I realized that you use your own capitalize() when you store the header keys. That means, Get() should use your way of keys, not as documented in FreeSWITCH wiki: c.Get("Job-UUID") returns empty string, and it takes a while to figure it out.

    I think it will be proper to capitalize the argument of Get() before looking up in the headers. Or, maybe introduce a new method, GetCaseInsensitive() or something.

    opened by ssinyagin 2
  • don't work playback

    don't work playback

    Hi! playback is dont't work help me

    Code package main

    import ( "fmt" "log" "github.com/fiorix/go-eventsocket/eventsocket" )

    const dest = "sofia/internal/303%test.fs" const dialplan = "&socket(localhost:9090 async)"

    func answer (ac *eventsocket.Connection) { ac.Execute("answer", "", false) ac.Execute("playback", "/usr/local/freeswitch/sounds/24Broadcaster.wav", false) }

    func main() { c, err := eventsocket.Dial("localhost:8021", "ClueCon") if err != nil { log.Fatal(err) } c.Send("events plain ALL") c.Send(fmt.Sprintf("bgapi originate %s %s", dest, dialplan)) for { ev, err := c.ReadEvent() if err != nil { log.Fatal(err) } fmt.Println("\nNew event") ev.PrettyPrint() var hangup_cause string if ev.Get("Event-Name") == "CHANNEL_ANSWER" { fmt.Println("Клиент ответил") go answer(c); return } else if ev.Get("Answer-State") == "hangup" { hangup_cause = ev.Get("Hangup-Cause") fmt.Println(hangup_cause) return } } c.Close() }

    opened by ghost 1
  • allow \r\n in order to use `sendevent`

    allow \r\n in order to use `sendevent`

    Example usage:

    event := fmt.Sprintf("sendevent SWITCH_EVENT_MESSAGE_QUERY\r\nmessage-account: %[email protected]%s", ToUser, ToRealm)
    _, err := crh.ESLConnection.Send(event)
    
    opened by eschmidbauer 1
  • Update eventsocket.go

    Update eventsocket.go

    go-eventsocket is getting crash while sending below api command api uuid_getvar {uuid} answered_time

    This fix will help to check the length before accessing it.

    opened by surendratiwari3 0
  • ReadEvent blocks forever on closed connection

    ReadEvent blocks forever on closed connection

    Easily reproducible:

    eslConn.Close()
    eslConn.Send("connect")
    ev, err := eslConn.ReadEvent()
    

    No errors are emitted to the ReadEvent in this case, since it just listens on channels with no timeout or check against the connection state, and the err is read off h.err by the call to Send, I believe.

    I propose adding a simple ReadWithTimeout, ReadWithDeadline, or ReadWithContext function to alleviate the issue, allowing us to back out of that select. Else, the connection error state needs to be persistent when ReadEvent is used.

    opened by nyxar 0
  • Fatal errors cause connection to close

    Fatal errors cause connection to close

    Hi,

    Is it strictly necessary to close the connection with FreeSWITCH when a fatal error occurs in readOne function (thus returning false to readLoop)?

    What are the implications of just ignoring it and keeping the connection open?

    Thank you.

    opened by kmyokoyama 1
  • some event updated in freeswitch 1.4.x

    some event updated in freeswitch 1.4.x

    when run client.go ,it says:

    2015/01/18 17:40:18 json: cannot unmarshal array into Go value of type string exit status 1

    when change to "c.Send("events plain ALL")" , it's ok.

    opened by transtone 5
Owner
Alexandre Fiori
Alexandre Fiori
Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

Advent of Code 2021 Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved

Kemal Ogun Isik 0 Dec 2, 2021
Zach Howell 0 Jan 4, 2022
File system event notification library on steroids.

notify Filesystem event notification library on steroids. (under active development) Documentation godoc.org/github.com/rjeczalik/notify Installation

Rafal Jeczalik 752 Jul 26, 2022
Unit tests generator for Go programming language

GoUnit GoUnit is a commandline tool that generates tests stubs based on source function or method signature. There are plugins for Vim Emacs Atom Subl

Max Chechel 62 Jul 8, 2022
Simple interface to libmagic for Go Programming Language

File Magic in Go Introduction Provides simple interface to libmagic for Go Programming Language. Table of Contents Contributing Versioning Author Copy

Krzysztof Wilczyński 12 Dec 22, 2021
The Gorilla Programming Language

Gorilla Programming Language Gorilla is a tiny, dynamically typed, multi-engine programming language It has flexible syntax, a compiler, as well as an

null 29 Apr 16, 2022
Elastic is an Elasticsearch client for the Go programming language.

Elastic is an Elasticsearch client for the Go programming language.

Oliver Eilhard 7k Aug 8, 2022
👩🏼‍💻A simple compiled programming language

The language is written in Go and the target language is C. The built-in library is written in C too

paco 26 Jul 22, 2022
Lithia is an experimental functional programming language with an implicit but strong and dynamic type system.

Lithia is an experimental functional programming language with an implicit but strong and dynamic type system. Lithia is designed around a few core concepts in mind all language features contribute to.

Valentin Knabel 6 Jun 14, 2022
accessor methods generator for Go programming language

accessory accessory is an accessor generator for Go programming language. What is accessory? Accessory is a tool that generates accessor methods from

masaushi 5 Jul 19, 2022
Http web frame with Go Programming Language

Http web frame with Go Programming Language

jk 0 Oct 17, 2021
A modern programming language written in Golang.

MangoScript A modern programming language written in Golang. Here is what I want MangoScript to look like: struct Rectangle { width: number he

PlebusSupremus1234 3 Nov 12, 2021
A stack oriented esoteric programming language inspired by poetry and forth

paperStack A stack oriented esoteric programming language inspired by poetry and forth What is paperStack A stack oriented language An esoteric progra

null 0 Nov 14, 2021
Oak is an expressive, dynamically typed programming language

Oak ?? Oak is an expressive, dynamically typed programming language. It takes the best parts of my experience with Ink, and adds what I missed and rem

Linus Lee 166 Jul 31, 2022
Besten programming language

Besten What holds this repository? Besten Lexer Besten Parser Besten Interpreter Besten Module Loader Besten Lexer Located in ./internal/lexer A set o

Alberto Elorza 2 Jun 13, 2022
🎅 A programming language for Advent of Code.

?? Adventlang My blog post: Designing a Programming Language for Advent of Code A strongly typed but highly dynamic programming language interpreter w

Andrew Healey 27 Mar 2, 2022
An experimental programming language.

crank-lang An experimental & interpreted programming language written in Go. Features C like syntax Written in Golang Interpreted Statically Typed Dis

inmicro 2 Dec 6, 2021
Gec is a minimal stack-based programming language

Gec is a minimal stack-based programming language

aiocat 1 May 22, 2022
Idiomatic Event Sourcing in Go

Event Sourcing for Go Idiomatic library to help you build Event Sourced application in Go. Please note The library is currently under development and

eventually 75 Jul 13, 2022