【发布时间】:2019-08-05 10:51:57
【问题描述】:
我正在努力理解 HTTP、HTTPS、WS 和 WSS。
我有一个托管在 HTTPS 端点上的 vue PWA。 在该应用程序中,我尝试连接到在 HTTP 端点上托管 SignalR-hub 的本地 PC。
我正在使用@aspnetcore/signalr 打字稿包。在开发机器上一切正常,但是当我尝试使用 PWA 时,我收到以下错误:
Error: Failed to start the connection: SecurityError: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.
我的连接构建器如下所示:
this.signalRConnection = new HubConnectionBuilder()
.withUrl(`http://${this.localIp}/${this.hubName}`, {
skipNegotiation: true,
transport: HttpTransportType.WebSockets
})
.configureLogging(LogLevel.Information)
.build();
我正在努力实现的目标是否可能?
【问题讨论】:
-
我猜问题是 "托管在 HTTPS 端点上。在该应用程序中,我尝试连接到本地 PC,该 PC 在 HTTP 端点。” 尝试让本地 PC 运行“HTTPS”。
-
这确实是我走的路。两者现在都在 HTTPS 上运行。 (还是)感谢你的建议。 @LGSon
标签: typescript websocket signalr-hub asp.net-core-signalr asp.net-core-3.0