pyVoIP icon indicating copy to clipboard operation
pyVoIP copied to clipboard

Add OPTIONS and CANCEL methods

Open disacod opened this issue 1 year ago • 3 comments

Exception was rise on OPTIONS request from PBX. And second, hangup() on CallState.DIALING was excepting and rtp port not releasing. Reason is no CANCEL method on hangup() function.

disacod avatar Sep 21 '23 08:09 disacod

Hi,

As far as I understood, hangup() is not what you call when trying to end a call during dialing. Faced the same issue and therefore added (or at least tried) the VoIPCall.cancel method.

Since CONTRIBUTION.md mentions feature freeze, I currently refrain from creating a pull request, please find the files to be replaced attached: commit_74174a5492c886ff914f93505b71baad8af047e5_issue167_issue177.zip

I'm not 100% sure if my implementation is according to spec but "works for me" :)

Please note that the fix provided by @obrain17 for #167 is already integrated as I needed it for testing.

Cheers!

chris-heo avatar Dec 21 '23 21:12 chris-heo

I am not sure what the dislike of the SIP OPTIONS Method is with this project. To be fair, maybe it is just very low on their radar. Honestly, it should be accepted that many modern SIP Providers, OTS SIP Stacks, and VoIP systems require it now.

However, rather than skip using this otherwise seemingly good project, I hacked support for it.

Below is the simple work needed. Forgive me for not providing a diff, as I literally just hacked this in the dist-packages to keep moving. If there is real interest I will fully test and formalize a commit.

Line 33 of init.py - add OPTIONS to method enums:

SIPCompatibleMethods = ["INVITE", "ACK", "BYE", "CANCEL", "OPTIONS"]

About Line 947 of SIP.py - add to the parser the elif needed to process OPTIONS, I added it between CANCEL and the catch-all else:

        elif message.method == "CANCEL":
            # TODO: If callCallback is None, the call doesn't exist, 481
            self.callCallback(message)  # type: ignore
            response = self.gen_ok(message)
            self.out.sendto(response.encode("utf8"), (self.server, self.port))
        elif message.method == "OPTIONS":
            self.callCallback(message)  # type: ignore
            response = self.gen_ok(message)
            self.out.sendto(response.encode("utf8"), (self.server, self.port))
        else:
            debug("TODO: Add 400 Error on non processable request")

It worked well enough to satisfy pjsip's "qualify."

Jbkcrash2 avatar Feb 05 '24 20:02 Jbkcrash2

Hi,

As far as I understood, hangup() is not what you call when trying to end a call during dialing. Faced the same issue and therefore added (or at least tried) the VoIPCall.cancel method.

Since CONTRIBUTION.md mentions feature freeze, I currently refrain from creating a pull request, please find the files to be replaced attached: commit_74174a5492c886ff914f93505b71baad8af047e5_issue167_issue177.zip

I'm not 100% sure if my implementation is according to spec but "works for me" :)

Please note that the fix provided by @obrain17 for #167 is already integrated as I needed it for testing.

Cheers!

In case somebody is interested in using these (as far as I can tell perfectly) working changes from @chris-heo, I've created a fork of pyVoIP v1.6.8 already including them: https://github.com/fussel132/pyVoIP-cancel-fb

Works well from a Raspberry Pi to AVMs FritzBox 7590. Thanks a lot!

fussel132 avatar Feb 25 '24 02:02 fussel132