Heroku Hobby Dyno:连接建立错误:net :: ERR_SSL_PROTOCOL_ERROR,服务器验证正常,但ALPN服务器不同意协议

时间:2018-11-22 06:11:25

标签: ssl heroku websocket heroku-ssl

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

我已经搜索了这个问题,从我看来,似乎只有在使用自定义域名的情况下才需要进行升级到Heroku Hobby之外的其他设置。如何通过Hobby dyno使SSL在我的my_app.heroku.com域上工作?

编辑:如果我运行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

1 个答案:

答案 0 :(得分:0)

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