[英]404 not found error using ServiceStack ServerEventsClient with Pipedream SSE API
I'm using Pipedream as a data source which provides event data via an SSE API.我使用Pipedream作为数据源,它通过 SSE API 提供事件数据。
As per the instructions here , I'm using the following code to subscribe to the SSE:按照此处的说明,我使用以下代码订阅 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.'但是,我收到一条
System.Net.WebException
其中包含消息“远程服务器返回错误:(404) 未找到”。
But if I use HttpClient
directly, it succeeds:但是如果我直接使用
HttpClient
,它就成功了:
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.当然,我想使用
ServerEventsClient
而不是HttpClient
来避免样板循环代码。 But why is ServerEventsClient
not working in this case?但是为什么
ServerEventsClient
在这种情况下不起作用?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.