douchao1864 2016-09-08 10:38
浏览 986
已采纳

为什么此websocket连接被拒绝?

I try to use the slack-sample bot from this blogpost https://www.opsdash.com/blog/slack-bot-in-golang.html . I've successfully created my api token, but i can not connect to the websocket server (the rtm.start request passs normally). I've get the error message

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

I've also tried to connect via a chrome app called Simple Web Socket Client and via a website based one tester. Both work well, i can establish a connection and i can send data.

I'm behind a proxy, but i only have troubles with golang's websocket.Dial function.

Does anybody know why this can happen?

I use:
- Windows 7 SP1 x64
- Golang 1.7.1 windows/amd64

Greetings Tonka

  • 写回答

1条回答 默认 最新

  • douqiu0351 2016-09-09 10:02
    关注

    If you are using gorilla/websocket, it has the ability to use a Proxy. From issue 107:

    import "net/http"
    
    ...
    
    var dialer = websocket.Dialer{
        Proxy: http.ProxyFromEnvironment,
    }
    

    If you are using golang.org/x/net you should switch to gorilla/websocket.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 wpf datagrid单元闪烁效果失灵
  • ¥15 券商软件上市公司信息获取问题
  • ¥100 ensp启动设备蓝屏,代码clock_watchdog_timeout
  • ¥15 Android studio AVD启动不了
  • ¥15 陆空双模式无人机怎么做
  • ¥15 想咨询点问题,与算法转换,负荷预测,数字孪生有关
  • ¥15 C#中的编译平台的区别影响
  • ¥15 软件供应链安全是跟可靠性有关还是跟安全性有关?
  • ¥15 电脑蓝屏logfilessrtsrttrail问题
  • ¥20 关于wordpress建站遇到的问题!(语言-php)(相关搜索:云服务器)