vialer/vialer-js

The Caller doesn't receive endcall response from the callee due to 480 Temp Unavailable is sent by the callee

Closed this issue · 7 comments

Description:

UserA: Zoiper App
UserB: VialerJS App

Use case:

User A -> FreeSwitch: INVITE (to: UserB)
FreeSwitch -> UserB: INVITE (from: UserA)
UserB -> FreeSwitch: 180 Ringing

At this time, UserB click endcall button on VialerJS App, it sends 480 to FreeSwitch. It's wrong scenario. It must send 486 Busy Here

For this reason, sometimes user A could not receive endcall from user B

Hi hpsony94,

You're right. This needs to be a 486. We'll look into it and come up with a fix.

By the way, do you have a good reference on how to give this a go with Freeswitch? It would be nice to test with a different PBX. We'll add some documentation for PBX setup to the project later.

Hi @jvanveen ,

I did follow this official doc from Freeswitch, please take it: https://freeswitch.org/confluence/display/FREESWITCH/WebRTC

Let me know if you need help. :)

BR,
Sony

Hi @jvanveen ,

Do you have any documents about using a custom adapter, a provider or an addon?

For example: I'd like to use my own system to provide contact, login, auth API? So that's the reason I need to custom those function to adapt with my own system.
It's good to me to know kind of API, docs about those feature.

Thanks in Advance,
Sony

Update for this ticket

I think it's not a fault of Vialer application layer. Let's look at a bit source code from vialer.
src/js/bg/plugins/calls/call/sip.js

/**
* Terminate a Call depending on it's current status.
*/
terminate() {
...
        // Calls with other statuses need some more work to end.
        try {
            if (this.state.status === 'invite') {
                this.setState({status: 'request_terminated'})
                **this.session.reject() // Decline an incoming call.**

reject() function has been triggered by SIP.js stack layer. I think vialer just should do what needed from SIP.js document.

Let's have a look at SIP.js stack API document.
https://sipjs.com/api/0.11.0/context/server/

reject([options])
Send a failure (300-699) response. By default, reject will send a 480 Temporarily Unavailable response with no body.

According to API document, I don't know the reason why by default reject will send a 480 TU response to SIP server. For this case, I think reject should identify which is the right case for "Busy Here" case.

I had to fix this issue by changing source code from sip.js

Here is my small fix, i don't know what will impact other func.
node_modules/sip.js/dist/sip.js

ServerContext.prototype.reject = function (options) {
options = Object.create(options || Object.prototype);
options.statusCode || (options.statusCode = 486);
options.minCode = 300;
options.maxCode = 699;
options.events = ['rejected', 'failed'];
return this.reply(options);
};

Hey @hpsony94

Sorry for the late response. About adapter documentation: there is not much documented yet. Your best bet is to check the source code from example implmentations like:
https://github.com/vialer/vjs-adapter-user-vg (user/login)
https://github.com/vialer/vjs-provider-contacts-vg (contacts)
https://github.com/vialer/vjs-mod-queues-vg (custom module for queues)

About the fix; yes that should be a 486. There is a ticket for it, but I can't say when it's going to be fixed.

Fixed in the develop branch