CodexBloom - Programming Q&A Platform

OCI Functions: Unresponsive Endpoint When Invoking with API Gateway

👀 Views: 191 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-09
oci api-gateway functions timeout Python

Can someone help me understand I've encountered a strange issue with I'm having trouble with an OCI Function that becomes unresponsive when invoked via the API Gateway. The function works perfectly when tested directly in the OCI console, but when accessed through the API Gateway, I receive a 504 Gateway Timeout behavior after about 30 seconds. The function itself is designed to handle data processing tasks and is expected to take around 20 seconds for completion. I have the following configuration for my API Gateway: ```json { "id": "my-api-gateway", "displayName": "My API Gateway", "protocol": "HTTP", "target": { "type": "FUNCTION", "function": { "functionId": "my-function-id", "namespaceId": "my-namespace-id" } }, "timeoutInMs": 30000 } ``` The OCI Function itself is defined in Python as follows: ```python import time def handler(ctx, data): time.sleep(20) # Simulating a long processing task return {'status': 'success', 'data': data} ``` Despite setting the timeout to 30 seconds, I still get the timeout behavior. I suspect it might be related to the invocation method or some underlying configuration in the API Gateway. I've also verified that the function has the correct permissions to be invoked from the API Gateway. In the logs, I see the following behavior message: `behavior: The function did not respond in time. (code: 504)`. Is there a specific configuration or best practice I might be missing that would help resolve this timeout scenario when invoking through the API Gateway? Any help would be greatly appreciated! I'm using Python LTS in this project. Thanks for your help in advance! Hoping someone can shed some light on this. What's the correct way to implement this?