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

shifted replies with outbound connection #72

Closed
tleseney opened this issue Apr 9, 2018 · 7 comments
Closed

shifted replies with outbound connection #72

tleseney opened this issue Apr 9, 2018 · 7 comments

Comments

@tleseney
Copy link
Contributor

tleseney commented Apr 9, 2018

Hi,

I think there be be an issue with the outbound connection setup. When I run something like:

var server = new esl.Server({port: 8022, myevent: true}, () => console.log('server up'));
server.on('connection::ready', (conn, id) => {
  conn.sendRecv('linger', (result) => console.log(result));
});

The output is:

{ headers: 
   [ { name: 'Content-Type', value: 'command/reply' },
     { name: 'Reply-Text', value: '+OK Events Enabled' },

This looks that the result of the previous command. The initial outbound code in Connection.js reads:

this.send('connect');

this.once('esl::event::CHANNEL_DATA::**', function() {
            self.subscribe(self.reqEvents, function() {
                self.emit('esl::ready');
            });
        });

Since send is used for sending connect, there are no registered command/reply listener. As a result, the subsequent subscribe gets the connect result and then the linger gets the subscribe result. It seems sendRecv should be used, with the callback, it could probably be simplified as:

this.sendRecv('connect', function() {
            self.subscribe(self.reqEvents, function() {
                self.emit('esl::ready');
            });
        });

since the esl::event::CHANNEL_DATA is actually the reply to the connect command.

Regards,

Tom

@englercj
Copy link
Owner

englercj commented Apr 9, 2018

Seems reasonable. I haven't worked on this lib for a while and don't have a freeswitch instance handy. If making this change works for you, feel free to put in a PR and I'll merge it.

@tleseney
Copy link
Contributor Author

Thanks Chad for the feedback. I'll prepare a PR.

@aalexgabi
Copy link
Contributor

I don't have a FreeSWITCH instance anymore either. I was wandering if it would take a long time to write an integration test for that using a Docker container with FreeSWITCH: https://hub.docker.com/r/bettervoice/freeswitch-container/

I think the same problem will be back for any PR so I thought a solution might be integration tests with a FreeSWITCH container.

@englercj
Copy link
Owner

Sounds great, I'd be happy to merge something that sets that up. Preferably with TravisCI.

@chitkosarvesh
Copy link

chitkosarvesh commented Jun 13, 2019

I think I am seeing similar issues. I am trying to run the "create_uuid" command on FreeSWITCH servers and I see almost comical responses from FreeSWITCH. I am not sure if it's my FS implementation or the node.js Library.
If anyone can help me out or point me in the right direction?

Here's what I see:

{"command":"create_uuid","output":{"headers":[{"name":"Content-Type","value":"api/response"},{"name":"Content-Length","value":4}],"hPtr":null,"body":"+OK\n"}}

{"command":"create_uuid","output":{"headers":[{"name":"Content-Type","value":"api/response"},{"name":"Content-Length","value":10}],"hPtr":null,"body":"3126106146"}}

{"command":"create_uuid","output":{"headers":[{"name":"Content-Type","value":"api/response"},{"name":"Content-Length","value":10}],"hPtr":null,"body":"Eric Medor"}}

{"command":"create_uuid","output":{"headers":[{"name":"Content-Type","value":"api/response"},{"name":"Content-Length","value":2}],"hPtr":null,"body":"0\n"}}

@englercj
Copy link
Owner

A PR never went in for this, so AFAIK this issue still exists.

@tleseney
Copy link
Contributor Author

tleseney commented Jun 14, 2019 via email

tleseney added a commit to tleseney/node-esl that referenced this issue Jun 19, 2019
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

4 participants