WebSocket握手期间出错:意外响应代码:502英寸

WebSocket握手期间出错:意外响应代码:502英寸,websocket,angular6,angular5,Websocket,Angular6,Angular5,我已经按照教程从 因为我正在尝试设置websocket连接,但在连接套接字后出现错误。错误为“WebSocket握手期间出错:意外响应代码:502” 我已经按照教程和步骤进行了操作,但是在连接套接字之后仍然会出现错误 websocket.service.ts import { Injectable } from '@angular/core'; import { Observable, Subject } from "rxjs-compat/Rx"; import { WebsocketServ

我已经按照教程从 因为我正在尝试设置websocket连接,但在连接套接字后出现错误。错误为“WebSocket握手期间出错:意外响应代码:502”

我已经按照教程和步骤进行了操作,但是在连接套接字之后仍然会出现错误

websocket.service.ts

import { Injectable } from '@angular/core';
import { Observable, Subject } from "rxjs-compat/Rx";
import { WebsocketService } from "./websocket.service";
import { map } from 'rxjs/operators';


let ws_scheme = window.location.protocol == "https:" ? "wss" : 
"ws";
let ws_path = ws_scheme + '://' +"61c725fa.ngrok.io" +
"/auth/forgot_password/";
const URL = ws_path;

export interface Message {
username: string;
}

@Injectable({
providedIn: 'root'
})
export class NotifierService {
public messages: Subject<Message>;

constructor(wsService: WebsocketService) { 
this.messages = <Subject<Message>>wsService
  .connect(URL).pipe(map((response: MessageEvent): Message => {
    let data = JSON.parse(response.data);
    return {
      username: data.message
    }
  }));
 }
}
我想解决这个问题。如果有人帮忙就好了

import { Injectable } from '@angular/core';
import { Observable, Subject } from "rxjs-compat/Rx";
import { WebsocketService } from "./websocket.service";
import { map } from 'rxjs/operators';


let ws_scheme = window.location.protocol == "https:" ? "wss" : 
"ws";
let ws_path = ws_scheme + '://' +"61c725fa.ngrok.io" +
"/auth/forgot_password/";
const URL = ws_path;

export interface Message {
username: string;
}

@Injectable({
providedIn: 'root'
})
export class NotifierService {
public messages: Subject<Message>;

constructor(wsService: WebsocketService) { 
this.messages = <Subject<Message>>wsService
  .connect(URL).pipe(map((response: MessageEvent): Message => {
    let data = JSON.parse(response.data);
    return {
      username: data.message
    }
  }));
 }
}
import { Component } from '@angular/core';
import { NotifierService } from './notifier.service';


@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {


title = 'ang-socket';
constructor(private notifier:NotifierService){
notifier.messages.subscribe(msg=>{
  console.log("response from websocket:" + msg);

})
}

private message = {
username: "abc@gmail.com"
};

sendMsg() {
console.log("new message from client to websocket: ", 
this.message);
this.notifier.messages.next(this.message);
this.message.username = "";
}


}