Git Product home page Git Product logo

goesl's Introduction

License Build Status Go 1.3 Ready Go 1.4 Ready Go 1.5 Ready

##FreeSWITCH Event Socket Library Wrapper for Go

GoESL is a small wrapper around FreeSWITCH Event Socket Library written in Go.

Point of this library is to fully implement FreeSWITCH ESL and bring outbound server as inbound client to you, fellow Go developer :)

WARNING

Before using this code, please read following discussion: #35

In short, I don't have time right now contributing to this project.

TODO?

You can find what still needs to be done at GoESL TODO

Examples

There are few different types of examples that can be found at GoESL Examples.

Feel free to suggest more examples :)

Contributions / Issues?

Please reach me over [email protected] or visit my website or submit new issue. I'd prefer tho if you would submit issue.

License

The MIT License (MIT)

Copyright (c) 2015 Nevio Vesic

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

goesl's People

Contributors

0x19 avatar harry-hao avatar jnewmano avatar spacetourist avatar tomasb avatar tongjichao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

goesl's Issues

GoESL Client Queues Calls Without Originating After 96 Attempts

Hello,

I've encountered a peculiar issue with the GoESL package during automation of dialing through FreeSWITCH. After successfully originating 96 calls, no further calls are processed. The FreeSWITCH CLI does not log any additional attempts, yet when I terminate the Go application, all the queued calls are suddenly processed.

My Environment Details:

  • FreeSWITCH Version: [Version 1.10.7]
  • FreeSWITCH Operating System: [Debian 11]
  • Go Version: [1.18.10]
  • Go Application Operating System: [Debian 11]

Issue Description:
My FreeSWITCH setup is configured to allow for 1,000 concurrent channels and 50 calls per second (CPS). Despite this, the system halts call processing after 96 calls. There are no errors or relevant logs in FreeSWITCH indicating why further calls are not being processed.

To rule out any conflicts with other packages, I created a minimal Go application with minimal dependencies. This application's sole function was to dial numbers to test the limits. The same issue occurred, which suggests that the problem is not related to other package dependencies.

A tcpdump on the server, filtered by my IP address, confirmed that the originate commands are reaching the server, but no further action is observed.

Steps to Reproduce:

  1. Set up FreeSWITCH to allow 1,000 concurrent channels and 50 CPS.
  2. Use the GoESL package to originate calls.
  3. Observe that after 96 successful calls, no further calls are processed.

Expected Behavior:
The GoESL client should continue to originate calls until it reaches the configured limits of FreeSWITCH or has no more dials left.

Actual Behavior:
The GoESL client stops originating calls after 96 attempts, with no further processing observed until the application is terminated.

Additional Information:
A Stack Overflow post with more context can be found here: https://stackoverflow.com/questions/77428926/goesl-with-temporal-calls-not-originating-past-certain-point-in-freeswitch/77450560#77450560

I would appreciate any guidance on further debugging steps or insights into what might be causing this behaviour.

QUESTION: events per socketConnection or not

it may seem naive, but i really do not know if the events are streamed per call (socketConnection) or all the events of all calls are received in every connection. I mean, if i want to listen to DTMF in calls, and have two simultaneous calls, if call A send 1 and call b send 2, is this the case that both calls receive both events? or every call receives it's related event (call A, 1 and call B, 2).
if the first is the case,isn't it a good idea to filter events for calls based on call_uuid and let pertinent calls have pertinent events?

how set log level

Hello, how can i change the log level for messages?

example

16:49:30.498 Debug ▶ DEBUG Waiting for connection message to be received ...

I want to avoid debug messages, i want info and upper to critical, not debug messages.

thanks

break with Gt new message: <nil>

package main

import (
    "flag"
    "fmt"
    . "github.com/0x19/goesl"
    "runtime"
    //"strings"
)

var (
    fshost   = flag.String("fshost", "localhost", "Freeswitch hostname. Default: localhost")
    fsport   = flag.Uint("fsport", 8021, "Freeswitch port. Default: 8021")
    password = flag.String("pass", "ClueCon", "Freeswitch password. Default: ClueCon")
    timeout  = flag.Int("timeout", 10, "Freeswitch conneciton timeout in seconds. Default: 10")
)

func main() {
    runtime.GOMAXPROCS(runtime.NumCPU())
    client, err := NewClient(*fshost, *fsport, *password, *timeout)
    if err != nil {
        Error("Error while creating new client: %s", err)
        return
    }
    go client.Handle()
    client.Send("events json ALL")
    for {
        msg, _ := client.ReadMessage()
        fmt.Printf("Gt new message: %+v\n", msg)
    }
}

break the flow and not received more messages

08:19:18.278 Debug ▶ DEBUG Waiting for connection message to be received ...
Gt new message:
08:19:18.278 Debug ▶ DEBUG Waiting for connection message to be received ...

This is embarasing... Note to myself (and everyone else)!

Alright, to do some background on this. This project was an idea of mine, while working in telecom sector in cpaas software as there were no golang based clients to interact with FS. At time, that sounded like a great idea to start the OS project. However, after some time, I've ditched pretty much whole telecom and moved to networking and lately into the blockchain.

Even tho explanation above is as-is, it's no excuse from me to have official Freeswitch docs linking to this repository which is old as hell and working to an extent in some basic prototype mode.

INSTEAD, I am now locking few hours a week to get this project working as it should be working.

Sorry for poor job of maintaining this repo. Lets sort this out and release sane version in upcoming months.

Best regards,
Nevio

Parse EOF

Hello, i use the same code as your example server_playback but enable receiving events by calling conn.Send("events plain all").
but very often i get errors that are mostly Parse EOF. end if i select json format for event "event json all" i get unexpected end of json.
also sometimes I get malformed MIME info. overall this made it impossible to use for listening to events.
I tried to fork your work and change it but with no success, and because on any case of error you close connection, first error means server stops.
note that the server and client and configuration works perfectly fine with nodejs esl client.
what the hell this parse EOF means?

thanks in advance for yourhelp

events of json type don't have their Content-Type header set

Sample code:

// Setup, connection handling, etc.

b := bytes.NewBufferString("event json DTMF\n")
b.WriteTo(conn)

// Some other code and then this runs in a goroutine for us

for {
    msg, err := conn.ReadMessage()

    // For JSON events this ends up being ""
    msgType := msg.GetHeader("Content-Type")

    switch msgType {
    case "text/disconnect-notice":
        done <- true
    case "text/event-plain":
        // assuming "event plain DTMF" is sent instead of JSON this will trigger
    case "text/event-json":
        // This will never trigger
    }

    //This is my current hack
    if eventName, ok := msg.Headers["Event-Name"]; ok {
        switch eventName {
        case "DTMF":
            logger.Errorf("DTMF: %s", msg.Headers["DTMF-Digit"])
        }
    }
}

Our current version of gesl:
revision = "1cd1251c682b6645e93bdc58ba48de5ed75fbd48"
version = "1.0"

[Program Crash while listening to events]

Hi,
I used the example code specified for the client connection, the origination of call went good, but after that the program gets crashed while listening to events(events json ALL), i am sure many have faced this issue, can somebody help me with this.

Regards
Abbasi

playback fail

golang 1.14.2 server_playback.go
playback is failed

Connection is closed on first unsuccessful result

Hi
I'm using this library to control calls using a client connection to freeswitch. Each call is parked in xml dialplan and on receiving park event my client application starts controlling the call by executing apps on channel using SendMsg. But if any app execution results in an error, for example calling execute on an already destroyed channel, whole esl socket is closed. Is there anyway to prevent such behaviour and continue receiving events?
thanks

Need a new developer?

Is this project still being maintained? Does it need personnel to join in? Maybe there is a bug found

type OutboundServer struct {
	net.Listener

	Addr  string `json:"address"`
	Proto string

	Conns chan SocketConnection
}

Conns have lock ,but it from the chennel

connect client has ERROR Expected auth/request content type. Got text/rude-rejection

goesl.NewClient(host, port, passwd, timeout)

has ERROR Expected auth/request content type. Got text/rude-rejection
goesl/client.go: 64,mistake here
if cmr.Get("Content-Type") != "auth/request" {
Error(EUnexpectedAuthHeader, cmr.Get("Content-Type"))
return fmt.Errorf(EUnexpectedAuthHeader, cmr.Get("Content-Type"))
}

system: centos 7.5

no readevent()?

hello,i have a question.
does this contains readevent()?
if exists,how to use?

>go get github.com/0x19/goesl fails

>go get github.com/0x19/goesl
# github.com/0x19/goesl
..\..\0x19\goesl\logger.go:26: too many arguments in call to log.Debug
..\..\0x19\goesl\logger.go:30: too many arguments in call to log.Error
..\..\0x19\goesl\logger.go:34: too many arguments in call to log.Notice
..\..\0x19\goesl\logger.go:38: too many arguments in call to log.Info
..\..\0x19\goesl\logger.go:42: too many arguments in call to log.Warning

go1.12 and go-logging

Any one else seeing this when building a project that uses goesl?

vendor/github.com/0x19/goesl/logger.go:26:11: too many arguments in call to log.Debug
	have (string, []interface {}...)
	want (...interface {})
vendor/github.com/0x19/goesl/logger.go:30:11: too many arguments in call to log.Error
	have (string, []interface {}...)
	want (...interface {})
vendor/github.com/0x19/goesl/logger.go:34:12: too many arguments in call to log.Notice
	have (string, []interface {}...)
	want (...interface {})
vendor/github.com/0x19/goesl/logger.go:38:10: too many arguments in call to log.Info
	have (string, []interface {}...)
	want (...interface {})
vendor/github.com/0x19/goesl/logger.go:42:13: too many arguments in call to log.Warning
	have (string, []interface {}...)
	want (...interface {})

can not receive CHANNEL_PARK message

1、I send INVITE to freeswitch .
2、freeswitch send CHANNEL_CREATE CHANNEL_CALLSTATE CHANNEL_PARK to goesl
3、goesl do not receive CHANNEL_PARK across client.ReadMessage()

image
image

client example falls

Hi. client example falls after few events were received without any message. I tried plain/json. And i've done a lot manipulations but still cant succeed.

Actually I'm trying to rewrite my my app from https://github.com/fiorix/go-eventsocket. All is this app do is just listen events all time and resends some via websocket.

Api Response

Is there a way to just get a response back, like most clients implement sendRecv? For example executing and getting the response back from "api fifo count".

Thanks,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.