我使用ruby coinbase-exchange gem,我通过复制并将其粘贴到irb中来执行代码。
只有当我将它作为websocket运行时才会发生这种情况 - 当我只是自己执行代码而没有套接字时,它运行正常。
执行以下代码时,
accounts = Array.new(2, Array.new)
rest_api.accounts do |resp|
accounts = resp
end
产生了这个错误:
Coinbase::Exchange::APIError: GET https://api.exchange.coinbase.com/accounts?: connection closed by server from /usr/local/lib/ruby/gems/2.3.0/gems/coinbase-exchange-0.1.2/lib/coinbase/exchange/adapters/em_http.rb:59:in `block in http_verb' from /usr/local/lib/ruby/gems/2.3.0/gems/eventmachine-1.2.0.1/lib/em/deferrable.rb:158:in `set_deferred_status' from /usr/local/lib/ruby/gems/2.3.0/gems/eventmachine-1.2.0.1/lib/em/deferrable.rb:198:in `fail' from /usr/local/lib/ruby/gems/2.3.0/gems/em-http-request-1.1.5/lib/em-http/client.rb:123:in `on_error' from /usr/local/lib/ruby/gems/2.3.0/gems/em-http-request-1.1.5/lib/em-http/client.rb:117:in `unbind' from /usr/local/lib/ruby/gems/2.3.0/gems/em-http-request-1.1.5/lib/em-http/http_connection.rb:205:in `block in unbind' from /usr/local/lib/ruby/gems/2.3.0/gems/em-http-request-1.1.5/lib/em-http/http_connection.rb:205:in `map' from /usr/local/lib/ruby/gems/2.3.0/gems/em-http-request-1.1.5/lib/em-http/http_connection.rb:205:in `unbind' from /usr/local/lib/ruby/gems/2.3.0/gems/em-http-request-1.1.5/lib/em-http/http_connection.rb:31:in `unbind' from /usr/local/lib/ruby/gems/2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:1481:in `event_callback' from /usr/local/lib/ruby/gems/2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:202:in `release_machine' from /usr/local/lib/ruby/gems/2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:202:in `ensure in run' from /usr/local/lib/ruby/gems/2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:205:in `run' from (irb):79 from /usr/local/bin/irb:11:in `<main>'
这里的问题是什么?我该如何解决它?