我有一个运行SignalR的第三方服务器。为了连接到该服务器并阅读消息,我创建了一个JavaScript代码,该代码应从ec2(Linux)实例上的NodeJS运行。问题是,当我尝试运行仅连接到服务器的代码时,出现此错误:..... node_modules / signalr / jquery.signalR.js:1085}(window.jQuery,窗口));^
ReferenceError:未定义窗口
什么样的窗户?我有仅ssh的linux服务器吗?我现有的JS代码是这样的:
const signalR = require("signalr"); //here i can't use @aspnet/signalr or @microsoft/signalr because those aren't compatible with SignalR that's on the 3rd party server. UGH Microsoft!
let connection = new signalR.HubConnectionBuilder().withUrl("https://myurl/signalr/hubName")
.configureLogging("warn")
.build();
connection.start().then(() => {
console.log("yeeey!");
}).catch((e) => {
console.log(e);
});
为了执行此操作,我在这里有什么选择?我已经使用官方的Amazon教程在ec2实例上安装了NodeJS,因此它应该是最新的最新版本-13.2
找到了解决方案。...This库解决了我的问题