Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTP unclosed socket warning #268

Open
kwnaidoo opened this issue Aug 8, 2024 · 0 comments
Open

RTP unclosed socket warning #268

kwnaidoo opened this issue Aug 8, 2024 · 0 comments

Comments

@kwnaidoo
Copy link

kwnaidoo commented Aug 8, 2024

Firstly excellent library! I have been trying out the v1.6.8 with a SIP account, the call is picked up correctly but as soon as I try to fetch the audio, I keep getting:

ResourceWarning: Enable tracemalloc to get the object allocation traceback
pyVoIP/RTP.py:341: ResourceWarning: unclosed <socket.socket fd=5, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('0.0.0.0', 17372)>
  self.sout = self.sin

def answer(call):
    try:
      call.answer()
      while call.state == CallState.ANSWERED:
         audio = call.read_audio()
         print(audio)
      call.hangup()
    except InvalidStateError:
      pass

I have also tried transcribing the audio using Assembly AI instead of just printing the raw bytes, same issue.

I took a peek into the library on line 341, but not too familiar with RTP so not sure what the issue is.

    def start(self) -> None:
        self.sin = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        # Some systems just reply to the port they receive from instead of
        # listening to the SDP.
        self.sout = self.sin
        self.sin.bind((self.inIP, self.inPort))
        self.sin.setblocking(False)

        r = Timer(0, self.recv)
        r.name = "RTP Receiver"
        r.start()
        t = Timer(0, self.trans)
        t.name = "RTP Transmitter"
        t.start()

Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant