Server-Sent Events
Context
Server-Sent Events (SSE) is a server push technology enabling a server to push events to a client via an HTTP connection. This technology is usually used to enable a server to push real-time data to a client, for example, a chat application or a real-time news update.
SSE primarily facilitates unidirectional real-time communication from the server to the client, such as streaming ChatGPT responses. In contrast to WebSockets, which provide bidirectional real-time communication, SSE is designed to be more lightweight and simpler to implement.
Prerequisites
The image for importing the AI application is SSE-compliant.
Constraints
- SSE supports only the deployment of real-time services.
- It supports only real-time services deployed using AI applications imported from custom images.
Calling an SSE Real-Time Service
The SSE protocol itself does not introduce new authentication mechanisms; it relies on the same methods as HTTP requests.
You can use one of the following authentication methods provided by ModelArts:
- Access Authenticated Using a Token
- Access Authenticated Using an AK/SK
- Access Authenticated Using an Application
The following section uses GUI software Postman for prediction and token authentication as an example to describe how to call an SSE service.
In normal cases, the value of Content-Type in the response header is text/event-stream;charset=UTF-8.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot