【问题标题】:Having trouble connecting to Alexa Voice Service with http/2 using Go使用 Go 通过 http/2 连接到 Alexa 语音服务时遇到问题
【发布时间】:2016-09-15 23:37:54
【问题描述】:

我正在尝试按照here under Creating an http/2 connection. 的描述建立一个下行通道我正在用 Go 编写我的客户端,我的代码如下:

api_endpoint := "https://avs-alexa-na.amazon.com/v1/directives"
access_token := fetchAccessToken() //retrieves token from local file
req, err := http.NewRequest("GET", api_endpoint, nil)
if(err != nil){
  panic(err)
}
req.Header.Add("authorization", fmt.Sprintf("Bearer %s",   access_token))
client := &http.Client{}
res, err := client.Do(req)
if(err != nil){
  panic(err)
}

问题是我的客户端在请求后给出以下错误:Get https://avs-alexa-na.amazon.com/v1/directives: malformed HTTP response "\x00\x00\x1e\x04\x00\x00\x00\x00\x00\x00\x01\x00 \x00\x10\x00\x00\x03\x00\x00\x00”。

我不知道如何处理这个问题。我怀疑 Go 出于某种原因没有使用 http/2,因此无法处理响应,但我不知道为什么会这样。我正在使用 Go 1.6.1,它应该会自动使用它。任何帮助将不胜感激。

【问题讨论】:

    标签: go http2 alexa-voice-service


    【解决方案1】:

    原来问题是 Go 1.6.1 中的一个错误导致 HTTP 客户端默认不使用 http/2。升级到 1.6.2 解决了这个问题。 Github 问题:https://github.com/golang/go/issues/14391

    【讨论】:

      猜你喜欢
      • 2013-03-07
      • 1970-01-01
      • 1970-01-01
      • 2015-05-09
      • 1970-01-01
      • 2019-05-29
      • 2019-11-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多