Skip to content

Commit

Permalink
mi: add timeout parameter for datagram connection
Browse files Browse the repository at this point in the history
  • Loading branch information
dariusstefan committed Dec 2, 2024
1 parent a36bb59 commit ccb1d13
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions opensips/mi/datagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def __init__(self, **kwargs):

if "datagram_port" not in kwargs:
raise ValueError("datagram_port is required for Datagram")


self.timeout = kwargs.get("timeout", 1)
self.ip = kwargs["datagram_ip"]
self.port = int(kwargs["datagram_port"])

Expand All @@ -44,7 +45,7 @@ def execute(self, method: str, params: dict):
udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
udp_socket.sendto(jsoncmd.encode(), (self.ip, self.port))
udp_socket.settimeout(5.0)
udp_socket.settimeout(self.timeout)
reply = udp_socket.recv(32768)
except Exception as e:
raise jsonrpc_helper.JSONRPCException(e)
Expand Down

0 comments on commit ccb1d13

Please sign in to comment.