Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit 2e01c16

Browse files
committed
[client] Implement timeout on HTTP requests / RabbitMQ consumption + heartbeat (#726)
1 parent e0c3a8e commit 2e01c16

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

pycti/api/opencti_api_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ def query(self, query, variables=None):
330330
verify=self.ssl_verify,
331331
cert=self.cert,
332332
proxies=self.proxies,
333+
timeout=300,
333334
)
334335
# If no
335336
else:
@@ -340,6 +341,7 @@ def query(self, query, variables=None):
340341
verify=self.ssl_verify,
341342
cert=self.cert,
342343
proxies=self.proxies,
344+
timeout=300,
343345
)
344346
# Build response
345347
if r.status_code == 200:
@@ -383,6 +385,7 @@ def fetch_opencti_file(self, fetch_uri, binary=False, serialize=False):
383385
verify=self.ssl_verify,
384386
cert=self.cert,
385387
proxies=self.proxies,
388+
timeout=300,
386389
)
387390
if binary:
388391
if serialize:

pycti/connector/opencti_connector_helper.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,8 @@ def run(self) -> None:
375375
# Connect the broker
376376
self.pika_credentials = pika.PlainCredentials(self.user, self.password)
377377
self.pika_parameters = pika.ConnectionParameters(
378+
heartbeat=10,
379+
blocked_connection_timeout=10,
378380
host=self.host,
379381
port=self.port,
380382
virtual_host=self.vhost,
@@ -466,6 +468,7 @@ def ping(self) -> None:
466468
"Connector state has been remotely reset",
467469
{"state": self.get_state()},
468470
)
471+
469472
if self.in_error:
470473
self.in_error = False
471474
self.connector_logger.info("API Ping back to normal")
@@ -1714,6 +1717,8 @@ def send_stix2_bundle(self, bundle: str, **kwargs) -> list:
17141717
self.connector_config["connection"]["pass"],
17151718
)
17161719
pika_parameters = pika.ConnectionParameters(
1720+
heartbeat=10,
1721+
blocked_connection_timeout=10,
17171722
host=self.connector_config["connection"]["host"],
17181723
port=self.connector_config["connection"]["port"],
17191724
virtual_host=self.connector_config["connection"]["vhost"],

0 commit comments

Comments
 (0)