R package nbastatR can't request data

January 13, 2019 923 views
API Ubuntu R

Having written some R code on my local machine, I am now running this code on my Ubuntu Digital Ocean Droplet. I have successfully installed the package nbastatR however when I attempt to run any of the data request functions, the code will hang as if the Droplet doesn’t have the abilty to pull data into my R session.

E.g., the following code will hang when run on my Droplet (hang as in RStudio will show the red stop sign until you terminate the script). This will run within 2 seconds on my local machine.

days_scores(game_dates = "2017-12-31", include_standings = F, return_message = T)

Is there something that needs to be enabled to allow the Droplet to access the ‘outside world’ via R?


1 Answer

Try disabling the firewall but only temporarily to see if that’s the culprit:

ufw disable

Run your code to see if it doesn’t hang. Make sure to restore the firewall afterwards:

ufw enable


  • Thanks - just tried this but unfortunately still hangs.

    • Can you run it and then observe in top if the RStudio process is using a lot of CPU? Another tool that helps shed light on things like this is strace. Run the script then open a terminal and note down the process ID of Rstudio or the script that’s running if it’s forked and then run this (make sure you have strace: apt install strace):

      strace -vvv -s 2048 -o /tmp/strace.log -p <pid>

      Let it run for a good minute. The content of the log file will tell what R is doing at a low level.


      • Thanks for your response - the R package author has advised that [1] This is a digital ocean issue probably related to the NBA stats api blocking certain ip addresses and header types…

        Is it possible for my Droplet to be assigned a different ip address? The main reason I purchased the Droplet was to automate tasks without having to leave my physical machine running.


        [1] https://github.com/abresler/nbastatR/issues/18

        • This is what the github issue is saying:

          This is a digital ocean issue probably related to the NBA stats api blocking certain ip addresses and header types

          Curious, what would it be a digital ocean issue when it’s the NBA stats API that’s blocking DO?


          • Yes a fair point. However is there something I can do to my Droplet so that, from the NBA stats API’s perspective, it’s not a malicious machine?


Have another answer? Share your knowledge.