繁体   English   中英

如何通过CloudFront访问aws websocket

[英]How to access aws websocket through CloudFront

我正在关注这个 url 来设置云前端。 https://nickzamosenchuk.medium.com/configure-amazon-cloudfront-cdn-for-websocket-connection-43c44b3f877c如何连接 WebSocket 到 ZCDE41C335EF373273? 我尝试了两种方法,但无法连接。

  let data = this.httpClient.get('https://<id>.cloudfront.net/dev').subscribe(datas => {
      console.log(datas);
    });

或者

this.socket = webSocket('wss://<id>.cloudfront.net/dev');

angular中的WebSocket怎么接?

是的,有一种方法,例如:

import { Injectable } from '@angular/core';
import { webSocket, WebSocketSubject } from 'rxjs/webSocket';

@Injectable({
  providedIn: 'root'
})
export class WebsocketExampleService {

  readonly url = "(wss|https)://<id>.cloudfront.net/";

  subject: WebSocketSubject<any>;

  constructor() {
    this.subject = webSocket({
      url: this.url,
      deserializer: msg => msg
    });
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM