tayler6000 / pyVoIP

Pure python VoIP/SIP/RTP library. Currently supports PCMA, PCMU, and telephone-event
https://pypi.org/project/pyVoIP/
GNU General Public License v3.0
234 stars 109 forks source link

Receiving RTP Packets on wrong port #82

Open Jan108 opened 2 years ago

Jan108 commented 2 years ago

In my application of pyVoIP I didn't receive the incoming audio from an incoming call.

After a packet capture, I realized that the SIP server (sipconnect.sipgate.de) sends the RTP packets to the wrong port (see packet_reading.zip). In the acceptance of the INVITE in packet 10 with 200 OK, we send the selected port 15940. But in the first received packet 33 the destination port is the 45336, which is the same port we send out RTP packets from.

The conclusion from it is, that the SIP server at sipconnect.sipgate.de ignores the port in the call acceptance, but sends its audio packets to the same port we send from. As a solution, I changed the sockets in the RTPClient to only one (see master of my fork). This way we send and receive on the same port.

This solves the problem and shouldn't interfere with the SIP/RTP definition. Using the same socket for send and receive is thread safe, so long only one thread sends and only one thread receives. Which is the case.

dani2112 commented 2 years ago

Seems to have solved my one way audio issues as well using a different VoIP provider! Thanks a lot!

xyc0815 commented 2 years ago

Are you behind a NAT?

Jan108 commented 1 year ago

No. In the current version, this doesn't work because of #76. But with 2.0 this should be fixed.