Comments (12)
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.
This PR seems to do the trick #5
from fsock.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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)
- Possible concurrent issue HOT 3
- Possible concurrency issue - events not being executed sequentially. HOT 6
- problem parsing fs cvs HOT 2
- cgrates/fsock: Issue with evfilters (Support to handle multiple Event values in the same Filter) HOT 3
- nil pointer panics handling bgapi requests
- Error starting example from README
- Does not read buffer correctly on slower connections. HOT 7
- Using SendMsgCmd from multiple Go routines concurrently HOT 3
- Support for bgapi HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fsock.