Issue with 504 Gateway Timeout Error When Initiating RTR Session using FalconPy #1075
-
Hello FalconPy Community, I'm encountering an issue with a 504 Gateway Timeout error when trying to initiate a Real Time Response (RTR) session using FalconPy. This error occurs despite the target device being valid and online. Goal: Source Code Example: from falconpy import RealTimeResponse
CLIENT_ID = "redacted"
CLIENT_SECRET = "redacted"
DEVICE_ID = "valid_device_id"
ORIGIN = "your_origin"
QUEUE_OFFLINE = False # Can be True or False
TIMEOUT = 30 # Timeout value
TIMEOUT_DURATION = "30s" # Timeout duration
def init_rtr_session():
falcon = RealTimeResponse(client_id=CLIENT_ID, client_secret=CLIENT_SECRET)
response = falcon.init_session(device_id=DEVICE_ID,
origin=ORIGIN,
queue_offline=QUEUE_OFFLINE,
timeout=TIMEOUT,
timeout_duration=TIMEOUT_DURATION)
return response
response = init_rtr_session()
print(response) Environment: FalconPy Version: 1.2.16 Details: {'status_code': 504, 'headers': {...}, 'body': {'meta': {...}, 'errors': [{'code': 504, 'message': "Gateway Timeout: Please provide trace-id='...' to support"}]}} I've checked the network configurations, device status, and adjusted timeout settings, but the issue persists. Any advice or suggestions to resolve this would be highly appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 4 replies
-
Hi @joseraeiro - Have you tried to a different host? The code as shown above successfully initializes a session for me (once I update the API details and device ID). |
Beta Was this translation helpful? Give feedback.
-
Hello @jshcodes.
Yes, I have, to the same result. |
Beta Was this translation helpful? Give feedback.
-
On a side note (not sure if this is relevant or not) when I try to initiate a RTR session with an offline host the response is different and appears to acknowledge the situation:
|
Beta Was this translation helpful? Give feedback.
-
Can you provide us the Trace ID mentioned above? |
Beta Was this translation helpful? Give feedback.
-
Sure thing, here's the complete response of such a request: {'status_code': 504, 'headers': {'Server': 'nginx', 'Date': 'Thu, 16 Nov 2023 09:14:53 GMT', 'Content-Type': 'application/json', 'Content-Length': '286', 'Connection': 'keep-alive', 'X-Content-Type-Options': 'nosniff', 'X-Cs-Traceid': '16efb526-d720-4356-a0bb-414de5bda8e5', 'X-Ratelimit-Limit': '6000', 'X-Ratelimit-Remaining': '5999', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'}, 'body': {'meta': {'query_time': 2.01e-07, 'powered_by': 'crowdstrike-api-gateway', 'trace_id': '16efb526-d720-4356-a0bb-414de5bda8e5'}, 'errors': [{'code': 504, 'message': "Gateway Timeout: Please provide trace-id='16efb526-d720-4356-a0bb-414de5bda8e5' to support"}]}} By the way, I'm not sure if this is relevant or not, but I have no trouble whatsover accessing other Crowdstrike API endpoints from the same machine, which should exclude any network related problems. |
Beta Was this translation helpful? Give feedback.
-
I've contacted Crowdstrike support and they've mentioned some problem with my access token, which is odd because if I use the token that I receive in these request on other API endpoints I'm able to do so with success, and hence that rules out any issue with the access token, am I right? Here's my current code: from falconpy import oauth2 as FalconAuth, RealTimeResponse
import http.client
http.client.HTTPConnection.debuglevel = 1
import logging
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
req_log = logging.getLogger('requests.packages.urllib3')
req_log.setLevel(logging.DEBUG)
req_log.propagate = True
# Replace these with your CrowdStrike API credentials
CLIENT_ID = ""
CLIENT_SECRET = ""
DEVICE_ID = "" # Replace with the target device ID
BASE_URL = "https://api.eu-1.crowdstrike.com" # Use the EU endpoint directly
def get_auth_token():
auth = FalconAuth.OAuth2(base_url=BASE_URL, client_id=CLIENT_ID, client_secret=CLIENT_SECRET)
token_response = auth.token()
if 'body' in token_response and 'access_token' in token_response['body']:
return token_response['body']['access_token']
else:
print("Error obtaining token:", token_response)
return None
def init_rtr_session(access_token):
falcon_rtr = RealTimeResponse(base_url=BASE_URL, access_token=access_token)
response = falcon_rtr.init_session(device_id=DEVICE_ID)
return response
# Rest of your script remains the same...
def main():
token = get_auth_token()
if token:
response = init_rtr_session(token)
print("Response from RTR Initiation:", response)
else:
print("Failed to obtain access token")
if __name__ == "__main__":
main() Which is producing the following output:
As I have mentioned earlier, I'm perfectly able to use the Bearer token that's represented by [REDACTED] in the output. |
Beta Was this translation helpful? Give feedback.
-
Hi @joseraeiro , |
Beta Was this translation helpful? Give feedback.
Is this a MSSP scenario? (i.e. is this endpoint associated with a child tenant and not the parent?)
We need to pass the
member_cid
of the child tenant when constructing the instance of the RTR Service Class if we are trying to initialize a session using Flight Control.