【问题标题】:Angular and SignalR throws 502Angular 和 SignalR 抛出 502
【发布时间】:2017-12-29 08:54:24
【问题描述】:

我已经使用这个很棒的教程https://blog.sstorie.com/integrating-angular-2-and-signalr-part-2-of-2/ 来实现一个有角度的信号器客户端。但是,如果我想从我的网站连接到托管在 Azure 上的服务,我会收到此错误

WebSocket connection to 'ws://...' failed: Error during WebSocket handshake: 
Unexpected response code: 502

我的 Azure APP 启用了 Websoket,并且我的服务中的 cors 设置为 *

我在 package.json 中的依赖项:

     "dependencies": {
    "@angular/animations": "^4.2.3",
    "@angular/common": "^4.2.3",
    "@angular/compiler": "^4.2.3",
    "@angular/compiler-cli": "^4.2.3",
    "@angular/core": "^4.2.3",
    "@angular/forms": "^4.2.3",
    "@angular/http": "^4.2.3",
    "@angular/platform-browser": "^4.2.3",
    "@angular/platform-browser-dynamic": "^4.2.3",
    "@angular/platform-server": "^4.2.3",
    "@angular/router": "^4.2.3",
    "@ngx-translate/core": "^7.0.0",
    "@ngx-translate/http-loader": "0.1.0",
    "admin-lte": "^2.3.11",
    "angular2-notifications": "^0.7.4",
    "bootstrap": "^3.3.7",
    "core-js": "^2.4.1",
    "font-awesome": "^4.7.0",
    "jquery": "^3.2.1",
    "ng2-validation": "^4.2.0",
    "rxjs": "^5.4.1",
    "signalr": "^2.2.2",
    "ts-helpers": "^1.1.2",
    "typescript": "2.3.4",
    "zone.js": "^0.8.12"
  },
  "devDependencies": {
    "@angular/cli": "^1.1.2",
    "@angular/compiler-cli": "^4.2.3",
    "@types/jasmine": "2.5.52",
    "@types/node": "^6.0.42",
    "codelyzer": "~3.0.1",
    "jasmine-core": "2.6.4",
    "jasmine-spec-reporter": "4.1.0",
    "karma": "1.7.0",
    "karma-chrome-launcher": "^2.1.1",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.1.0",
    "karma-remap-istanbul": "^0.6.0",
    "protractor": "~5.1.2",
    "ts-node": "3.0.6",
    "tslint": "^5.4.3",
    "typescript": "2.3.4"
  }

我的 angluar-cli.json 包含在脚本部分:

  "scripts": [
        "../node_modules/jquery/dist/jquery.js",
        "../node_modules/signalr/jquery.signalr.js",
        ...
      ],

【问题讨论】:

    标签: angular azure asp.net-web-api signalr


    【解决方案1】:

    <httpRuntime targetFramework="4.7" /> 添加到我的web.config 后,错误消失了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-12
      • 2020-04-12
      • 2020-08-01
      • 1970-01-01
      相关资源
      最近更新 更多