0

我有一个简单的应用程序,客户端通过 wss 连接在页面加载时发送加入 websocket 通道的请求。我已将我的应用程序部署到 domain 的 heroku my_app.heroku.com。每当我打开我的网站时,我都会收到错误消息Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR。我知道这是一个 SSL 问题,而且要使用 Heroku 的 SSL,您必须使用业余爱好者帐户。所以,我将应用程序升级为爱好者(一天前),但它并没有解决问题。

我已经用谷歌搜索了这个问题,从我看到的情况来看,除了升级到 Heroku Hobby 之外,似乎只有在使用自定义域名时才需要额外的设置,而我不是。如何my_app.heroku.com使用 Hobby dyno 让 SSL 在我的域上工作?

编辑:如果我跑步,curl -vI <my_app>.heroku_app.com我会得到以下信息:

curl -vI https://<my_app>.herokuapp.com
* Rebuilt URL to: https://<my_app>.herokuapp.com/
*   Trying __.___.___.___...
* Connected to <my_app>.herokuapp.com (__.___.___.___) port 443
(#0)
* found 148 certificates in /etc/ssl/certs/ca-certificates.crt
* found 592 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256
*        server certificate verification OK
*        server certificate status verification SKIPPED
*        common name: *.herokuapp.com (matched)
*        server certificate expiration date OK
*        server certificate activation date OK
*        certificate public key: RSA
*        certificate version: #3
*        subject: C=US,ST=California,L=San Francisco,O=Heroku\, Inc.,CN=*.herokuapp.com
*        start date: Wed, 19 Apr 2017 00:00:00 GMT
*        expire date: Mon, 22 Jun 2020 12:00:00 GMT
*        issuer: C=US,O=DigiCert Inc,OU=www.digicert.com,CN=DigiCert SHA2
High Assurance Server CA
*        compression: NULL
* ALPN, server did not agree to a protocol
> HEAD / HTTP/1.1
> Host: <my_app>.herokuapp.com
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Server: Cowboy
Server: Cowboy
< Connection: keep-alive
Connection: keep-alive
< Content-Type: text/html; charset=utf-8
Content-Type: text/html; charset=utf-8
< Content-Length: 1154
Content-Length: 1154
< Date: Thu, 22 Nov 2018 08:39:51 GMT
Date: Thu, 22 Nov 2018 08:39:51 GMT
< Via: 1.1 vegur
Via: 1.1 vegur
4

1 回答 1

0

终于找到这个问题后,我找到了答案。我一直认为问题是由于在 Heroku 上设置 SSL 证书,但这是由于我的客户端代码。根据我所遵循的教程,WS 连接是“wss://my_app.herokuapp.com:80/subscribe”。删除端口号是修复。

于 2018-11-27T04:56:57.900 回答