I'm using Javascript to originate a new outbound call. The Session ready() method returns inconsistent results when the call is answered. When it returns false, the session's causecode value is 0. Am I doing something wrong here, or could it be a bug? <br>
<br>A simple test script and log output is below. I'm executing the script from the console using jsrun. I've noticed that switch_core_state_machine.c logs a state change when ready() returns true. I'm not sure if this is significant, but it might indicate a race condition.<br>
<br><div><br><font class="Apple-style-span" face="'courier new', monospace">---- test script ----<br><br>new_session = new Session( "{ignore_early_media=true}sofia/internal/1000%192.168.1.10" );<br>if ( new_session.ready() ) {<br>
console_log( "info", "Call connected.\n" );<br> // play audio....<br>}<br>else {<br> // the causecode is 0 when this fails on a successful call attempt<br> console_log("err", "Call not connected. Cause: " + new_session.cause + "[" + new_session.causecode + "]\n" );<br>
}<br><br><br>---- call connected log ----<br><br>[NOTICE] sofia.c:4851 Channel [sofia/internal/1000] has been answered<br>[DEBUG] switch_ivr_originate.c:3273 Originate Resulted in Success: [sofia/internal/1000]<br>[DEBUG] mod_spidermonkey.c:2866 (sofia/internal/1000) State Change CS_CONSUME_MEDIA -> CS_SOFT_EXECUTE<br>
[DEBUG] switch_core_session.c:1027 Send signal sofia/internal/1000 [BREAK]<br><font class="Apple-style-span" color="#CC0000">[DEBUG] switch_core_state_machine.c:314 (sofia/internal/1000) Running State Change CS_SOFT_EXECUTE</font><br>
[INFO] originate.js:1 Call connected.<br>[DEBUG] switch_core_state_machine.c:354 (sofia/internal/1000) State SOFT_EXECUTE<br>[DEBUG] mod_sofia.c:544 SOFIA SOFT_EXECUTE<br>[DEBUG] switch_core_state_machine.c:200 sofia/internal/1000 Standard SOFT_EXECUTE<br>
[DEBUG] switch_core_state_machine.c:354 (sofia/internal/1000) State SOFT_EXECUTE going to sleep<br><br><br>---- call not connected log ----<br><br>[NOTICE] sofia.c:4851 Channel [sofia/internal/1000] has been answered<br>[DEBUG] switch_ivr_originate.c:3273 Originate Resulted in Success: [sofia/internal/1000]<br>
[DEBUG] mod_spidermonkey.c:2866 (sofia/internal/1000) State Change CS_CONSUME_MEDIA -> CS_SOFT_EXECUTE<br>[DEBUG] switch_core_session.c:1027 Send signal sofia/internal/1000 [BREAK]<br><font class="Apple-style-span" color="#CC0000">[ERR] originate.js:1 Call not connected. Cause: NONE(0)</font><br>
[DEBUG] switch_channel.c:2261 (sofia/internal/1000) Callstate Change ACTIVE -> HANGUP<br>[NOTICE] mod_spidermonkey.c:3066 Hangup sofia/internal/1000 [CS_SOFT_EXECUTE] [NORMAL_CLEARING]<br></font><br><br></div>