为什么这个 websocket 连接被拒绝?

Why is this websocket connection being refused?

我尝试使用这篇博文 https://www.opsdash.com/blog/slack-bot-in-golang.html 中的 slack-sample 机器人。我已经成功创建了我的 api 令牌,但是我无法连接到 websocket 服务器(rtm.start 请求正常通过)。我收到错误消息

dial tcp 54.242.95.213:443: connectex: No connection could be made because the target machine actively refused it

我还尝试通过名为 Simple Web Socket Client 的 chrome 应用程序和基于一个测试仪的网站进行连接。两者都很好,我可以建立连接并且可以发送数据。

我在代理后面,但我只有 golang 的 websocket.Dial 函数有问题。

有人知道为什么会发生这种情况吗?

我使用:
- Windows 7 SP1 x64
- 高朗 1.7.1 windows/amd64

问候 通卡

如果您正在使用 gorilla/websocket, it has the ability to use a Proxy. From issue 107:

import "net/http"

...

var dialer = websocket.Dialer{
    Proxy: http.ProxyFromEnvironment,
}

如果您使用的是 golang.org/x/net,则应切换到 gorilla/websocket。