angular - 'instanceof' 的右侧在 SignalR 1.1.2 中不可调用
问题描述
将 @aspnet/signalr 从1.0.0升级到1.1.2后,调用startConnection() 时出现以下错误:
解析握手响应时出错:TypeError:'instanceof' 的右侧不可调用
这是我的服务:
@Injectable()
export class SignalRService {
careworkerTrckInfo = new EventEmitter<GeoLocationCareWorkerTrackSignalR>();
connectionEstablished = new EventEmitter<Boolean>();
private connectionIsEstablished = false;
private serverTimeoutInMilliseconds = 50000; // 50 Second
private _hubConnection: HubConnection;
constructor(
@Inject(APP_CONFIG) private appConfig: IAppConfig) {
this.createConnection();
this.startConnection();
}
private createConnection() {
const url = `${this.appConfig.apiEndpoint}/notifications`;
this._hubConnection = new HubConnectionBuilder()
.withUrl(url)
.build();
this._hubConnection.serverTimeoutInMilliseconds = this.serverTimeoutInMilliseconds;
}
private startConnection() {
this._hubConnection
.start()
.then(() => {
this.connectionIsEstablished = true;
this.connectionEstablished.emit(true);
})
.catch(err => {
console.log('Error while establishing connection.');
});
}}
它曾经工作过!
解决方案
以下代码在我的 index.html 中:
<script>
var global = global || window;
// var Buffer = Buffer || []; --> remove or comment this line
var process = process || {
env: {
DEBUG: undefined
},
version: []
};
</script>
我删除(评论)缓冲区,它解决了我的问题。
推荐阅读
- node.js - 使用 Azure 存储/Blob 服务设置 Azure Node.js 应用服务的最佳方式是什么
- hashicorp-vault - 将 P12 安全地存储在公共数据中心
- python-3.x - 基于树的模型的最优超参数调整
- javascript - 在比较多个系列 highstock 中更改 yAxis 值以显示点值而不是百分比变化值
- swift - 从 Swift 在 Bash 终端中创建文件
- angular - Popover/tooltip ui bootstrap angular 6 under condition
- javascript - 如何在 JavaScript AJAX 调用中收集仅包含指定键的数组?
- sql - 如何使用 SQL(Oracle)从给定的数字中查找代码名称
- python - conda install 和 conda update 有什么区别?
- python - Python 请求以编程方式获取预先格式化为字典的开发工具表单数据