redd icon indicating copy to clipboard operation
redd copied to clipboard

Request forbidden by administrative rules.

Open bh4cyi opened this issue 8 years ago • 4 comments
trafficstars

Hi, I add this piece of code to get the error information:

begin
  puts "starting main thread....."
  stream_all!(bot, subreddit_list)
rescue Exception => e
  puts "big error we need to fix: #{e}"
end

After several hours without any activity, I got "Request forbidden by administrative rules.". How can I fix this?

Redd got a HTTP::TimeoutError error (Read timed out after 5 seconds), retrying...
Redd got a HTTP::TimeoutError error (execution expired), retrying...
Redd got a Redd::ServerError error (<!doctype html>
<html>
<title>Ow! -- reddit.com</title>
<style>
body{text-align:c...), retrying...
Redd got a HTTP::TimeoutError error (Read timed out after 5 seconds), retrying...
Redd got a HTTP::TimeoutError error (Read timed out after 5 seconds), retrying...
Redd got a HTTP::TimeoutError error (Read timed out after 5 seconds), retrying...
Redd got a HTTP::TimeoutError error (Read timed out after 5 seconds), retrying...
Redd got a HTTP::TimeoutError error (execution expired), retrying...
Redd got a HTTP::TimeoutError error (Read timed out after 5 seconds), retrying...
Redd got a HTTP::TimeoutError error (Read timed out after 5 seconds), retrying...
big error we need to fix: <html><body><h1>403 Forbidden</h1>
Request forbidden by administrative rules.

bh4cyi avatar Mar 22 '17 03:03 bh4cyi

Hi! Sorry for the late reply, I've been a bit busy recently.

And unfortunately I don't think I can help you either. 403s are usually thrown when the access has expired or the the bot is requesting something outside its scope, but those should raise InvalidAccess and InsufficientScope. And if you're doing something that reddit doesn't allow you, the body should say {"message": "Forbidden", "error": 403}. So Request forbidden by administrative rules is something I've never seen when working with reddit.

Are you possibly behind a corporate or educational firewall that prevents you from visiting certain subreddits or blocks certain keywords?

avinashbot avatar Mar 26 '17 13:03 avinashbot

I was running the bot in my house, so I don't think that's because the firewall. It takes long to repeat this bug. I'll keep my eyes on it.

bh4cyi avatar Mar 27 '17 22:03 bh4cyi

Hmm...that's interesting, now I'm curious too. To avoid cluttering logs, Redd only prints out the first few characters of the error message, but you can get the whole thing by calling error.response.raw_body on the exception like so:

begin
  ...
rescue Redd::Forbidden => e
  if e.response.raw_body.include?("administrative rules")
    puts e.response.headers.inspect
    puts e.response.raw_body
    raise e
  end
end

Maybe that'll clear up some of the mystery. Keep me posted if you run into this error again!

avinashbot avatar Mar 28 '17 00:03 avinashbot

Marking as "on hold" since I really have no idea what's causing this.

avinashbot avatar Apr 05 '17 20:04 avinashbot