- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我们有一个连接到服务器的客户端。服务器可以通过http 和https 两种方式访问。https 服务器包含 CA 认证的 SSL key 。由于客户端在公司代理后面运行,我们使用了以下命令:
const events = this.proxy ? new EventSource(this.source, { proxy: this.proxy }) : new EventSource(this.source)
因此,当前命令仅在连接到http://server时才有效。 .
如果我们尝试连接到 https://server ,收到以下错误:
Event { type: 'error', status: 400, message: 'Bad Request' }
所以我们尝试设置:
const events = this.proxy ? new EventSource(this.source, {https: {proxy: this.proxy, rejectUnauthorized: false} } ) : new EventSource(this.source)
或
const events = this.proxy ? new EventSource(this.source, {https: {proxy: this.proxy} } ) : new EventSource(this.source)
在这两种情况下,我们都收到超时错误。
我们有什么遗漏的吗?我们应该如何在代理后面设置https连接?
最佳答案
解决方案是使用“global-agent”或“global-tunnel-ng”包:
// Support working behind a corporate proxy
const MAJOR_NODEJS_VERSION = parseInt(process.version.slice(1).split('.')[0], 10);
if (MAJOR_NODEJS_VERSION >= 10) {
// `global-agent` works with Node.js v10 and above. Proxy env should be defined "export GLOBAL_AGENT_HTTP_PROXY=http://127.0.0.1:8080"
require('global-agent').bootstrap()
} else {
// `global-tunnel-ng` works only with Node.js v10 and below. Uses npm proxy settings
require('global-tunnel-ng').initialize()
}
const events = new EventSource(this.source)
阅读此处了解更多信息:https://www.npmjs.com/package/global-agent
关于node.js - 带有 https 代理的 NodeJS EventSource 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57507582/
我正在使用 https://github.com/streamdataio/eventsource-android/ 的 EventSource REPO我创建了一个 onConnect ();方法,
我正在开发一个由三个 Windows 服务和几个普通 Windows 应用程序 (.exe) 组成的大型产品。现在我们要转移到 ETW 和语义日志记录,并使用 Microsoft.Diagnostic
我正在研究使用 DDD+CQRS+EventSourcing 制作应用程序,但在弄清楚如何进行用户身份验证时遇到了一些麻烦。 用户本质上是我领域的一部分,因为他们对客户负责。我正在使用 ASP.NET
从 EventSource 开始API 我写的最学术的例子。 问题是我总是出错,我找不到任何有用的信息。当我加载 home.html , JS 脚本停在 source.onerror ;我将它打印到控
我不知道如何使用 JavaScript 从 EventSource 捕获事件。我正在这样做,但是“正在运行”永远不会出现在控制台中。 var es = new EventSource(
我创建了一个自托管 ServiceStack 服务,该服务基于其 showcase chat application 在 Windows 服务中运行。 。 但是,我没有进一步讨论的是尝试将客户端编写为
我正在使用 EventSource 登录到 ETW。我们正在使用 .Net Framework 4.5。 由于我处于开发的初级阶段,我将经常更改我的 EventSource 子类中的方法签名。我真的不
我正在使用 EventSource 在我的库中记录事件。该库是跨平台的,这意味着它可以被 linux/mac 用户使用。我知道 EventSource 在 Windows 上是如何工作的。用户可以使用
对 EventSource 行为有点困惑。 它连接良好并保持连接状态,直到收到第一条消息。 当我发送一条 data: something\n\n 消息时,连接断开并创建新连接。 使用 Content-
我在项目前端使用 JavaScript EventSource。 有时,浏览器和服务器之间的连接失败或服务器崩溃。在这些情况下,EventSource 会在 3 秒后尝试重新连接,如文档中所述。 但它
我正在尝试创建一个页面,该页面使用 EvenSource 对象(在 javascript 中)来创建服务器发送事件( cometd )。我阅读了很多关于它的教程,但没有找到可以解释以下问题的教程: 当
我正在尝试在我的新项目中使用 CQRS 和 EventSorcing。我正在遵循 Greg Young 几年前建议的方式(Mark Nijhof 实现 - http://cre8ivethought.
我有一个使用 EventSourcing 的 DDD 项目。目前有许多聚合根,其中许多都有实体的集合。甚至更多 - 一些实体具有其他实体的集合。 问题:出于审计目的读取 EventSourcing 事
我正在尝试为 Yesod 中的网站构建聊天功能,我希望它有一个所有已连接用户的列表。我认为最好的方法是将人员添加到连接上的用户列表中,并在他们离开时将其删除。如果保持连接打开,响应似乎应该阻塞,所以我
我有一个用例,我想发布一个非状态更改事件作为触发器。 In the vast majority of cases, the Aggregates will publish events by ap
我正在尝试使用 dddd 实现一个事件源系统。目前,我正在努力了解我的事件如何以及在何处跨越限界上下文的边界。 假设有两个限界上下文: 产品管理 物流系统 产品管理拥有关于产品的所有知识。为了简化,它
TL;DR 更新:无论是从客户端关闭 EventSource 还是完全关闭客户端,php 都会继续在后端执行并且无法报告 connection_aborted() 的正确值.为什么会这样? 我一直在
我正在尝试实现 Server Sent Events使用 Spring SseEmitter如本 Youtube video 中所述. 我能够启动事件流并从服务器发送的事件中接收数据。 但是,我可以看
我正在实现 FullCalendar 作为我的团队的假期日历。我希望团队中的每个成员的项目都有不同的颜色,因此我使用 ajax 请求从数据库中提取列表。我想知道如何将此列表组合到事件数组中以创建 ev
刚刚将我的 fullcalendar 更新到 1.6.3,将 jQuery 更新到 1.10.2突然我的日历不再显示来自“eventSources”的事件。我在文档中找不到任何说明需要更改的内容。为了
我是一名优秀的程序员,十分优秀!