尝试 运行 服务器端 NodeJS 上的 Signalr 客户端
Trying to run Signalr client on the server side NodeJS
我有一个 运行SignalR 的第 3 方服务器。为了连接到该服务器并读取消息,我创建了一个 javascript 代码,该代码应该 运行 来自 ec2 (Linux) 实例上的 NodeJS。问题是,当我尝试 运行ning 我的代码只连接到服务器时,我收到了这个错误:
.....node_modules/signalr/jquery.signalR.js:1085
}(window.jQuery, window));
^
ReferenceError: window 未定义
什么样的window?我有一个仅支持 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);
});
为了 运行 我有什么选择?我已经使用亚马逊官方教程在 ec2 实例上安装了 NodeJS,因此它应该是最新版本 - 13.2
找到解决方案.... This 库解决了我的问题
请这样写:
import * as signalR from '@aspnet/signalr';
我有一个 运行SignalR 的第 3 方服务器。为了连接到该服务器并读取消息,我创建了一个 javascript 代码,该代码应该 运行 来自 ec2 (Linux) 实例上的 NodeJS。问题是,当我尝试 运行ning 我的代码只连接到服务器时,我收到了这个错误: .....node_modules/signalr/jquery.signalR.js:1085 }(window.jQuery, window)); ^
ReferenceError: window 未定义
什么样的window?我有一个仅支持 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);
});
为了 运行 我有什么选择?我已经使用亚马逊官方教程在 ec2 实例上安装了 NodeJS,因此它应该是最新版本 - 13.2
找到解决方案.... This 库解决了我的问题
请这样写:
import * as signalR from '@aspnet/signalr';