Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple async calls get mixed up #39

Open
thehunmonkgroup opened this issue Nov 15, 2016 · 2 comments
Open

Multiple async calls get mixed up #39

thehunmonkgroup opened this issue Nov 15, 2016 · 2 comments

Comments

@thehunmonkgroup
Copy link

I use the utility function listed below to make individual API calls via this package, with FS as an instance of esl.client():

FreeswitchUtil.prototype.runFreeswitchCommand = function(command, callback, FS) {
  callback = callback ? callback : function() {};
  FS = FS ? FS : this.FS;
  this.logger.debug(format("Running command '%s'", command));
  FS.api(command)
  .then(function(res) {
    this.logger.debug(format("Command '%s' result headers: %s", command, JSON.stringify(res.headers)));
    this.logger.debug(format("Command '%s' result body: %s", command, res.body));
    callback(null, res.body);
  }.bind(this))
  .catch(function(error) {
    if (_.isObject(error.res)) {
      this.logger.error(format("Command '%s' error: %s", command, error.res.body));
      callback(error.res.body, null);
    }
    else {
      this.logger.error(format("Command '%s' error: %s", command, JSON.stringify(error)));
      callback(error, null);
    }
  }.bind(this));
}

When I put the system under load with a lot of async calls happening, I see logging output that looks like certain commands get overwritten by other incoming commands:

debug: Command 'conference 585 vid-res-id 18 3' result body: Non-Existant ID 15

The ID in that response should not be 15, as I'm sending 18 in the command. The command variable is scoped to my function, so it doesn't make any sense to me that it's getting overwritten in the function itself.

Curious if I've set things up wrong in my support function, or if this package has some issue handling lots of simultaneous calls, or if it's some bug in FreeSWITCH?

FYI, running version 4.0.1 of this package, as it seems to be the newest that runs on node 10.x

@shimaore
Copy link
Owner

The mixing-up of commands in client mode is a known issue in 4.x which has been mitigated in 5.x.

@thehunmonkgroup
Copy link
Author

I don't supposed that fix can be backported to 4.x, or 5.x made to work with node 10.x?

The latter is probably better, as some major distributions still have 10.x in their packaging systems. I did make a first try at fixing 5.x for node 10.x, but wasn't able to get it working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants