Coder Social home page Coder Social logo

Comments (12)

tomponline avatar tomponline commented on July 30, 2024

The other type of 'events' on the channel, such as command responses and events do not sender the headers:

https://github.com/cgrates/fsock/blob/master/fsock.go#L314

from fsock.

tomponline avatar tomponline commented on July 30, 2024

This PR seems to do the trick #5

from fsock.

danbogos avatar danbogos commented on July 30, 2024

Hey Tom,

Would need a bit of time to check the impact since we use processing of
the events in our session manager.

Thanks,
DanB

On 10.06.2014 23:10, TomP wrote:

This PR seems to do the trick #5 #5


Reply to this email directly or view it on GitHub
#4 (comment).

from fsock.

tomponline avatar tomponline commented on July 30, 2024

Thanks. How do you use the API response string currently? Do you extract the content-length line party and then use that as a length to read the response body? How do you know where the header starts (as the response text has the empty newline that delimits the header from the body removed)

from fsock.

danbogos avatar danbogos commented on July 30, 2024

We only process events from ReadEvents and check for error in case of
SendApiCmd (use that for commands like call originate). The only issue is
ReadEvents for us and that is why I need to check it. However not enough
hours on the day :-).

DanB.
Am 14.06.2014 11:47 schrieb "TomP" [email protected]:

Thanks. How do you use the API response string currently? Do you extract
the content-length line party and then use that as a length to read the
response body? How do you know where the header starts (as the response
text has the empty newline that delimits the header from the body removed)


Reply to this email directly or view it on GitHub
#4 (comment).

from fsock.

tomponline avatar tomponline commented on July 30, 2024

I know what you mean :)

The err return value shouldn't be affected by this change, as the "-ERR" bit you look for is still in the response body of the API command not the headers. I was concerned that would be a problem too.

from fsock.

danbogos avatar danbogos commented on July 30, 2024

Yes from that perspective not but ReadEvents receives another response ....

DanB.
Am 14.06.2014 11:53 schrieb "TomP" [email protected]:

I know what you mean :)

The err return value shouldn't be affected by this change, as the "-ERR"
bit you look for is still in the response body of the API command not the
headers. I was concerned that would be a problem too.


Reply to this email directly or view it on GitHub
#4 (comment).

from fsock.

tomponline avatar tomponline commented on July 30, 2024

I'm not following, sorry. ReadEvents will still decode the header via readEvent, so the next event on the socket should not be affected. This PR just throws away the header as AFAIK it only contains the content-length when sending API responses from Freeswitch. For the other types of responses; dispatchEvent and command reply, the headers are not sent back to the calling function. Cheers

from fsock.

danbogos avatar danbogos commented on July 30, 2024

Thanks Tom,

Merged it now.

Was on the way today morning and imagining dispatchEvent will get the
part with header/body so I see now the patch makes sense.
Btw, out of curiosity, are you using fsock in any serious project or
just testing?

DanB

On 14.06.2014 12:12, TomP wrote:

I'm not following, sorry. ReadEvents will still decode the header via
readEvent, so the next event on the socket should not be affected.
This PR just throws away the header as AFAIK it only contains the
content-length when sending API responses from Freeswitch. For the
other types of responses; dispatchEvent and command reply, the headers
are not sent back to the calling function. Cheers


Reply to this email directly or view it on GitHub
#4 (comment).

from fsock.

tomponline avatar tomponline commented on July 30, 2024

Thanks Dan. Yes we are using this for the company I work for. We are using it to control outbound calls from a PBX server and will in the future use it to control 'call backs' initiated from a web site.

A few years ago I wrote a similar library to fsock in PHP, but for this project we wanted to use something with more concurrency in the language - hence Go and fsock.

We use the hash API in Freeswitch to set a global variable that assigns new calls to a particular fsock client process ID.

That way when a process starts up it effectively 'registers' with Freeswitch by setting its PID into the global hash key. Then when a new call arrives the dialplan extracts this value and sets it into the call's channel variables.

Each fsock client then subscribes to channel events containing a channel var of its PID - so that it gets all events for the calls its responsible for.

from fsock.

danbogos avatar danbogos commented on July 30, 2024

Hey Tom,

Interesting mechanism, might use ideas out of it if requirements show up
here ;).

Btw, what is the reason you would like to have your requests being
balances around more fsock connections?

DanB

On 16.06.2014 10:42, TomP wrote:

Thanks Dan. Yes we are using this for the company I work for. We are
using it to control outbound calls from a PBX server and will in the
future use it to control 'call backs' initiated from a web site.

A few years ago I wrote a similar library to fsock in PHP, but for
this project we wanted to use something with more concurrency in the
language - hence Go and fsock.

We use the hash API in Freeswitch to set a global variable that
assigns new calls to a particular fsock client process ID.

That way when a process starts up it effectively 'registers' with
Freeswitch by setting its PID into the global hash key. Then when a
new call arrives the dialplan extracts this value and sets it into the
call's channel variables.

Each fsock client then subscribes to channel events containing a
channel var of its PID - so that it gets all events for the calls its
responsible for.


Reply to this email directly or view it on GitHub
#4 (comment).

from fsock.

tomponline avatar tomponline commented on July 30, 2024

Yeah it works pretty well. We don't really load balance the fsock clients - its more that we have one active process that keeps tabs on how the calls are progressing, and then when we need to do a code rollout the active process stops accepting new calls after the a new process starts up and takes new calls (by overwriting the global hash variable with its PID). That way we can gracefully rollout new code without transferring call state.

from fsock.

Related Issues (10)

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.