Skip to content

[mod_event_socket] FS Closes Call after Transfer #580

@zek

Description

@zek

We're developing some custom FS library on PHP and I noticed and came across with a bug so I just tested this behavior with some open-source libraries and came across same result.

So when I execute transfer app in outbound socket server, it sometimes hangups call with has executed the last dialplan instruction error.

2020-04-25 22:42:43.258052 [NOTICE] switch_core_state_machine.c:386 sofia/internal/phone12@172.254.1.4:5061 has executed the last dialplan instruction, hanging up.
2020-04-25 22:42:43.258052 [NOTICE] switch_core_state_machine.c:388 Hangup sofia/internal/phone12@172.254.1.4:5061 [CS_EXECUTE] [NORMAL_CLEARING]

Dialplan is as below.

<extension name="menu20">
<condition field="destination_number" expression="^menu20$">
<action application="socket" data="172.254.2.1:6969 async full"/>
</condition>
</extension>

This Demo app simply accepts call, speaks then makes transfer to menu20 (socket 172.254.2.1:6969). And this is not working as I expect.

var esl = require('modesl');

var esl_server = new esl.Server({ port: 6969, host: '172.254.2.1', myevents: true }, function () {
  console.log("esl server is up");
});

esl_server.on('connection::ready', function (conn, id) {
  console.log('new call ' + id);
  conn.call_start = new Date().getTime();

  conn.execute('answer', null, '', function () {
    conn.execute('speak', 'flite|awb|bip bop', '', function () {
      conn.execute('transfer', 'menu20 XML internal', '', function () {
        conn.disconnect();
      });
    });
  });

  conn.on('esl::end', function (evt, body) {
    this.call_end = new Date().getTime();
    var delta = (this.call_end - this.call_start) / 1000;
    console.log("Call duration " + delta + " seconds");
  });
});

However If I just disconnect socket without waiting transfer to be completed as below, it loops forever and call doesn't hangup.

var esl = require('modesl');

var esl_server = new esl.Server({ port: 6969, host: '172.254.2.1', myevents: true }, function () {
  console.log("esl server is up");
});

esl_server.on('connection::ready', function (conn, id) {
  console.log('new call ' + id);
  conn.call_start = new Date().getTime();

  conn.execute('answer', null, '', function () {
    conn.execute('speak', 'flite|awb|bip bop', '', function () {
      conn.execute('transfer', 'menu20 XML internal');
      conn.disconnect();
    });
  });

  conn.on('esl::end', function (evt, body) {
    this.call_end = new Date().getTime();
    var delta = (this.call_end - this.call_start) / 1000;
    console.log("Call duration " + delta + " seconds");
  });
});

I've also tried with bridge loopback/menu20 and this is working but just messes CDRs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions