简体   繁体   English

使用带有 Pipedream SSE API 的 ServiceStack ServerEventsClient 找不到 404 错误

[英]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在这种情况下不起作用?

ServiceStack 的服务器事件客户端仅适用于 ServiceStack 的服务器事件功能,即它不能用于使用 3rd Party SSE 流。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用ServiceStack ServerEventsClient的现有身份验证 - Existing authentication with ServiceStack ServerEventsClient 加密ServiceStack ServerEvents客户端消息传递 - Encrypting ServiceStack ServerEventsClient messaging 在调用 Start 之前使用 ServiceStack 的 ServerEventsClient 注册 displayName - Registering displayName with ServiceStack's ServerEventsClient before invoking Start microsoft face api 错误资源未找到(404) - microsoft face api error Resource not found(404) 在ServiceStack上找不到给定的密钥错误 - The given key was not found error on ServiceStack SignalR 错误使用高级集线器 api 和 MVC4 - “/echo/negotiate 404 Not Found Error” - SignalR error using high level hub api with MVC4 - "/echo/negotiate 404 Not Found Error" 使用ServiceStack的Soap12ServiceClient将请求对象发送到使用ServiceStack.Factory配置的服务时出现404错误 - Getting a 404 error when using ServiceStack's Soap12ServiceClient to send a request object to a service configured with ServiceStack.Factory 远程服务器返回错误:(404)找不到。 使用Facebook图形API时 - The remote server returned an error: (404) Not Found. when using facebook graph api 订阅用户到ServiceStack中的SSE频道 - Subscribe user to a SSE channel in ServiceStack Apple Store Connect Api http 请求返回错误404未找到 - Apple Store Connect Api http request returns error 404 not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM