Reputation: 4497
I'm using Pipedream as a data source which provides event data via an SSE API.
As per the instructions here, I'm using the following code to subscribe to the SSE:
var client = new ServerEventsClient("https://api.pipedream.com/sources/dc_mXugEA/sse")
{
EventStreamRequestFilter = req => req.AddBearerToken("[MYTOKEN]"),
OnMessage = message => Console.WriteLine(message.Json)
}.Start();
However, I get a System.Net.WebException
with the message 'The remote server returned an error: (404) Not Found.'
But if I use HttpClient
directly, it succeeds:
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "[MYTOKEN]");
using var reader = new StreamReader(await client.GetStreamAsync("https://api.pipedream.com/sources/dc_mXugEA/sse"));
while (!reader.EndOfStream)
{
Console.WriteLine($"Received message: {await reader.ReadLineAsync()}");
}
Of course, I want to use ServerEventsClient
instead of HttpClient
to avoid the boilerplate looping code. But why is ServerEventsClient
not working in this case?
Upvotes: 1
Views: 492
Reputation: 143319
ServiceStack’s Server Events clients only works with ServiceStack’s Server Events feature, I.e. it can’t be used to consume a 3rd Party SSE stream.
Upvotes: 2