【问题标题】:Pusher not able to establish connectionPusher 无法建立连接
【发布时间】:2019-12-26 02:09:11
【问题描述】:

我正在尝试使用推送器连接到 Liquid 交易所的 Stream API。 Documentation here

我已经构建了一个符合 Pusher 库文档的函数。 Link to that here 我当前的代码如下所示:

require 'pusher-client'
channels_client = PusherClient::Socket.new('LIQUID', {
      ws_host: 'tap.liquid.com'
  })

并运行它给我一个错误消息:

D,[2019-08-20Txx:xx:xx.xxxxxx #xxxxx] 调试 -- : 绑定 pusher:connection_builted 到 pusher_global_channel

D,[2019-08-20Txx:xx:xx.xxxxxx #xxxxx] 调试 -- : 绑定 pusher:connection_disconnected 到 pusher_global_channel

D,[2019-08-20Txx:xx:xx.xxxxxx #xxxxx] 调试 -- : 绑定推送器:错误 到 pusher_global_channel

D,[2019-08-20Txx:xx:xx.xxxxxx #xxxxx] 调试 -- : 绑定推送器:ping 到 pusher_global_channel

如果我尝试在第一个命令之后运行它:

channels_client.connect

...它拒绝连接。

C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/pusher-client-0.6.2/lib/pusher-client/websocket.rb:17:in `initialize': 无法建立连接,因为目标机器 主动拒绝了。 - 连接(2)“tap.liquid.com”端口 80 (Errno::ECONNREFUSED)

【问题讨论】:

    标签: ruby stream pusher


    【解决方案1】:

    错误来自 websocket 第 17 行中的 tcpsocket.new (Ruby https://ruby-doc.org/stdlib-2.5.1/libdoc/socket/rdoc/TCPSocket.html):https://github.com/pusher-community/pusher-websocket-ruby/blob/master/lib/pusher-client/websocket.rb

    ws_host tap.liquid.com 80 好像无效,https://pusher.com/docs/channels/library_auth_reference/pusher-websockets-protocol

    我尝试过使用安全连接,至少在浏览器中,得到了 404 的 ws 和无效请求,在这种情况下,对于 https (https://tap.liquid.com/) 来说这很好。

    您需要在客户端配置中配置 ssl,但 pusher-client gem 以及我发现的其他 gem 已经很老了。也许明智的做法是切换到更新的库,例如 https://github.com/pusher/pusher-http-ruby/blob/master/README.md

    该示例包含激活 SSL 的选项。

    【讨论】:

      猜你喜欢
      • 2018-08-11
      • 1970-01-01
      • 1970-01-01
      • 2015-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-10
      • 1970-01-01
      相关资源
      最近更新 更多