尝试运行Rails应用程序时发生超时错误

时间:2020-04-14 18:21:44

标签: ruby-on-rails ruby postgresql rubygems

我正在尝试填充以下PostgreSQL数据库:https://github.com/toddwschneider/nba-shots-db。我遵循所有必要的步骤,包括安装Ruby,PostgreSQL,Rails等。但是,当我尝试运行bundle exec rake db:setup时,出现超时错误:

44738@christine-cluster-m:~/nba-shots-db$ bundle exec rake db:setup
Created database 'nba-shots-db_development'
Created database 'nba-shots-db_test'
-- enable_extension("plpgsql")
   -> 0.0119s
-- create_table("closest_defender_aggregates", {:force=>:cascade})
   -> 0.0182s
-- create_table("delayed_jobs", {:force=>:cascade})
   -> 0.0129s
-- create_table("players", {:force=>:cascade})
   -> 0.0125s
-- create_table("shots", {:force=>:cascade})
   -> 0.0124s
-- enable_extension("plpgsql")
   -> 0.0133s
-- create_table("closest_defender_aggregates", {:force=>:cascade})
   -> 0.0170s
-- create_table("delayed_jobs", {:force=>:cascade})
   -> 0.0134s
-- create_table("players", {:force=>:cascade})
   -> 0.0124s
-- create_table("shots", {:force=>:cascade})
   -> 0.0131s
rake aborted!
RestClient::Exceptions::ReadTimeout: Timed out reading data from server
/home/44738/.rvm/gems/ruby-2.5.3/gems/rest-client-2.0.2/lib/restclient/request.rb:733:in `rescue in transmit'
/home/44738/.rvm/gems/ruby-2.5.3/gems/rest-client-2.0.2/lib/restclient/request.rb:642:in `transmit'
/home/44738/.rvm/gems/ruby-2.5.3/gems/rest-client-2.0.2/lib/restclient/request.rb:145:in `execute'
/home/44738/.rvm/gems/ruby-2.5.3/gems/rest-client-2.0.2/lib/restclient/request.rb:52:in `execute'

...

Caused by:
Net::ReadTimeout: Net::ReadTimeout
/home/44738/.rvm/gems/ruby-2.5.3/gems/rest-client-2.0.2/lib/restclient/request.rb:448:in `net_http_do_request'
/home/44738/.rvm/gems/ruby-2.5.3/gems/rest-client-2.0.2/lib/restclient/request.rb:721:in `block in transmit'
/home/44738/.rvm/gems/ruby-2.5.3/gems/rest-client-2.0.2/lib/restclient/request.rb:715:in `transmit'
/home/44738/.rvm/gems/ruby-2.5.3/gems/rest-client-2.0.2/lib/restclient/request.rb:145:in `execute'
/home/44738/.rvm/gems/ruby-2.5.3/gems/rest-client-2.0.2/lib/restclient/request.rb:52:in `execute'
/home/44738/nba-shots-db/app/lib/nba_stats_client.rb:156:in `get'

...

Tasks: TOP => db:setup => db:seed
(See full trace by running task with --trace)

因此,看起来它既创建了两个数据库,又开始创建表,这似乎是一个好兆头。但是然后我收到超时错误。它与我在Hadoop集群中执行此操作有关吗?对于所有这些,我非常陌生,因此如果此错误很明显,请提前道歉。另外,请告诉我添加其他信息是否对我有帮助。预先感谢您的帮助!

2 个答案:

答案 0 :(得分:1)

gem尝试load data from https://stats.nba.com/stats/,并且该服务器没有响应。要解决该问题,您无能为力。

也许可以通过打开issue on their GitHub page来通知gem的维护者。也许维护者也可以访问服务器,并且可以看看。

答案 1 :(得分:0)

RestClient正在超时。 RestClient是用于发出Web请求的工具。根据您的堆栈跟踪,调用站点位于app / lib / nba_stats_client.rb的第156行。看看您要RestClient在那做什么。它只是在访问给定的URL中超时。尝试自己访问该URL(将其粘贴到浏览器中或使用curl),您可能会看到相同的超时。

在运行Rails服务器的机器上,您可以使用curl等工具来形成相同的请求,并且很可能会看到相同的超时:

curl <url>