Christine
Christine

Reputation: 35

Timeout error when trying to run a Rails app

I am trying to populate the following PostgreSQL database: https://github.com/toddwschneider/nba-shots-db. I follow all the necessary steps, including installing Ruby, PostgreSQL, Rails, etc. But when I try to run bundle exec rake db:setup I get a timeout error:

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)

So it looks like its creating both databases, and starts creating tables, which seems like a good sign. But then I get the timeout error. Could it have something to do with the fact that I'm doing this in a Hadoop cluster? I am extremely new to all of this so apologies in advance if this error is obvious. Also let me know if it would be helpful for me to add any additional information. Thanks in advance for the help!

Upvotes: 0

Views: 1097

Answers (2)

spickermann
spickermann

Reputation: 106782

The gem tries to load data from https://stats.nba.com/stats/ and that server doesn't respond. There is not much you can do to fix that problem.

Perhaps notify the maintainer of the gem about this by opening an issue on their GitHub page. Maybe the maintainers have access to the server too and can have a look.

Upvotes: 1

Stephen Crosby
Stephen Crosby

Reputation: 1261

RestClient is timing out. RestClient is a tool for making web requests. According to your stack trace, the call site is line 156 of app/lib/nba_stats_client.rb. Take a look at what you're asking RestClient to do there. It is simply timing out in accessing the given URL. Try accessing that URL yourself (paste it into a browser or use curl) and you'll likely see the same timeout.

From the machine running your rails server, you could use a tool like curl to form the same request and most likely see the same timeout:

curl <url>

Upvotes: 0

Related Questions