SSE events issue in azure functions(Golang)

Hrithik 5 Reputation points
2024-09-29T07:15:50.55+00:00

I have deployed code written in golang in Azure Functions with the Content-Type set to text/event-stream. However, when I attempt to hit the API using Postman, the request keeps sending continuously without completion. Additionally, no logs appear in the Postman console, and the request does not seem to return any response.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,058 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. LeelaRajeshSayana-MSFT 15,561 Reputation points Microsoft Employee
    2024-09-30T20:10:30.23+00:00

    Hi @Hrithik Greetings! Welcome to Microsoft Q&A forum. Thank you for posting this question here.

    the request keeps sending continuously without completion

    I understand that you have set the Content-Type of the function to text/event-stream However, it is possible that the Azure function is not receiving any events from the calling end point in the expected format. Hence there is output being returned from Azure functions back to the calling end point, which is Postman in this case. Test the application locally and see if the function gets when you call the local end point URL.

    Furthermore, Azure functions have a limited support to HTTP streams or SSE events. The HTTP trigger function is designed to operate only for a max period of 230 seconds once triggered and the connection gets terminated. When a client application is calling a http triggered function app and the function app is taking more than 4 minutes to respond, it times out. It is not recommended to use HTTP Tigger to process event streams or any long running operations. Please refer the Function App timeout settings for reference.

    Azure functions support for SSE

    I am not sure if this feature is supported in Go yet. There is a preview feature available in Azure functions that use Python to Support HTTP streams. This feature uses the FastAPI request and response methods to accept and return the SSE events. Please also refer this discussion on HTTP streaming response support for Azure functions for additional information on this. Consider using the Python code sample instead of Go and see if you get the expected events returned from the Azure function.

    Hope this helps!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.