Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSE support #990

Open
andrewfg opened this issue Mar 24, 2023 · 2 comments
Open

SSE support #990

andrewfg opened this issue Mar 24, 2023 · 2 comments
Labels
feature New feature request

Comments

@andrewfg
Copy link

andrewfg commented Mar 24, 2023

Issue

Old style REST API devices have GET/PUT commands whereby the client can read/write data to the server (i.e. a client driven, polling mechanism). But nowadays many REST API devices also support Server Sent Eventing (SSE) whereby the server can inform the client directly if anything changes. (i.e. a server event driven mechanism).

Example

This is often the case in home automation devices (e.g. Philips Hue) where the server device can (say) notify the client that a light was turned on or a temperature has changed.

Analog

Some implementers use SSE to send event notifications. But some use WebSockets instead. The implementation is slightly different, but the purpose is the same. => So see #83

Proposed Solution

Mockoon should add the following features..

  • Ability for a client to open an SSE connection to Mockoon server.
  • (Ditto ability for the client to open a WebSocket connection to Mockoon server).
  • Ability to define response payloads (usually JSON) that Mockoon server can send over the SSE (resp. WebSocket) connection.
  • Above mentioned responses are sent with a delay of (0 .. n seconds) after the connection is opened (or even a random delay to simulate real life events).
  • Above mentioned responses would allow variable contents, as with existing Mockoon responses, to simulate real life.

Signed-off-by: Andrew Fiddian-Green software@whitebear.ch

@255kb 255kb added the feature New feature request label Apr 4, 2023
@isuru89
Copy link
Contributor

isuru89 commented Nov 22, 2023

I think this issue could get more popular with the rise of the "GPT" world. Because, those GPT APIs uses SSEs to transfer the real-time generating contents.

The reasons I see:

  1. Popularity of GPT APIs.
  2. Cost of Usage: Also, these APIs are commercialized or rate-limited. So, using actual APIs are limited in development or test environments due to the additional incurring cost to the organization. Hence, developers would expect a mocking API in their local machine/non-production environments.
  3. Predictability: Such GPT APIs tend to produce non-deterministic results even with the same inputs. So, sometime troubleshooting a scenario would not be easy and may require a help from mocking API to simulate with such troublesome responses and behaviors.

--
Edit:
Would love to start a PoC around this

@yunqiangwu
Copy link

我也想要这种功能

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request
Projects
None yet
Development

No branches or pull requests

4 participants