Was trying to initiate outbound calls, but found that calls were being terminated after only 6 seconds. Looking through the PCAP logs, I saw that my voip provider was providing a 200 OK (INVITE) response for the call initiation, with from and to tags in the header. pyVoIP responded with an ACK message that provided the correct From tag in the header, but randomly generated a To tag. This caused the ACK to not be accepted by the server side, causing repeated attempts to complete the handshake before the call was terminated.
Was able to resolve the problem by modifying SIP.py at line 1565 by changing
ackMessage += (
f"To: {request.headers['To']['raw']};tag="
+ f"{self.gen_tag()}\r\n"
)
to
to_header = request.headers['To']['raw']
if 'tag' in request.headers['To']:
ackMessage += f"To: {to_header};tag={request.headers['To']['tag']}\r\n"
else:
ackMessage += f"To: {to_header}\r\n"
A similar problem exists in the responses to BYE requests at line 1308 of SIP.py, where the current code copies the From tag from the request and then randomly generates a To tag. The code in question:
okResponse += (
f"From: {request.headers['From']['raw']};tag="
+ f"{request.headers['From']['tag']}\r\n"
)
okResponse += (
f"To: {request.headers['To']['raw']};tag="
+ f"{self.gen_tag()}\r\n"
)
Correcting these errors caused the handshakes to complete properly and calls to continue until intentionally terminated.
Was trying to initiate outbound calls, but found that calls were being terminated after only 6 seconds. Looking through the PCAP logs, I saw that my voip provider was providing a 200 OK (INVITE) response for the call initiation, with from and to tags in the header. pyVoIP responded with an ACK message that provided the correct From tag in the header, but randomly generated a To tag. This caused the ACK to not be accepted by the server side, causing repeated attempts to complete the handshake before the call was terminated.
Was able to resolve the problem by modifying SIP.py at line 1565 by changing
to
A similar problem exists in the responses to BYE requests at line 1308 of SIP.py, where the current code copies the From tag from the request and then randomly generates a To tag. The code in question:
Correcting these errors caused the handshakes to complete properly and calls to continue until intentionally terminated.