nextcloud / news-updater

:newspaper: Fast, parallel feed updater for the News app; written in Python
GNU General Public License v3.0
105 stars 24 forks source link

HTTP Error 400: Bad Request #8

Closed mideuger closed 7 years ago

mideuger commented 7 years ago

I'm having an issue running the updater using the REST API.

nextcloud_news-updater | Traceback (most recent call last):
nextcloud_news-updater |   File "/usr/local/lib/python3.6/site-packages/nextcloud_news_updater/api/updater.py", line 69, in run
nextcloud_news-updater |     self.before_update()
nextcloud_news-updater |   File "/usr/local/lib/python3.6/site-packages/nextcloud_news_updater/api/web.py", line 76, in before_update
nextcloud_news-updater |     self.client.get(self.api.before_cleanup_url, self.auth)
nextcloud_news-updater |   File "/usr/local/lib/python3.6/site-packages/nextcloud_news_updater/api/web.py", line 61, in get
nextcloud_news-updater |     response = urlopen(req, timeout=timeout)
nextcloud_news-updater |   File "/usr/local/lib/python3.6/urllib/request.py", line 223, in urlopen
nextcloud_news-updater |     return opener.open(url, data, timeout)
nextcloud_news-updater |   File "/usr/local/lib/python3.6/urllib/request.py", line 532, in open
nextcloud_news-updater |     response = meth(req, response)
nextcloud_news-updater |   File "/usr/local/lib/python3.6/urllib/request.py", line 642, in http_response
nextcloud_news-updater |     'http', request, response, code, msg, hdrs)
nextcloud_news-updater |   File "/usr/local/lib/python3.6/urllib/request.py", line 570, in error
nextcloud_news-updater |     return self._call_chain(*args)
nextcloud_news-updater |   File "/usr/local/lib/python3.6/urllib/request.py", line 504, in _call_chain
nextcloud_news-updater |     result = func(*args)
nextcloud_news-updater |   File "/usr/local/lib/python3.6/urllib/request.py", line 650, in http_error_default
nextcloud_news-updater |     raise HTTPError(req.full_url, code, msg, hdrs, fp)
nextcloud_news-updater | urllib.error.HTTPError: HTTP Error 400: Bad Request
nextcloud_news-updater | 2017-02-12 21:43:46,217 - Nextcloud News Updater - INFO - Calling before update url:  http://nextcloud/index.php/apps/news/api/v1-2/cleanup/before-update
nextcloud_news-updater | 2017-02-12 21:43:46,310 - Nextcloud News Updater - ERROR - HTTP Error 400: Bad Request: Trying again in 30 seconds
app_1           | 172.18.0.12 - nextcloud [12/Feb/2017:21:43:46 +0000] "GET /index.php/apps/news/api/v1-2/cleanup/before-update HTTP/1.1" 400 13678 "-" "Python-urllib/3.6"

I've tried using both the configuration file and the CLI with the same result.

BernhardPosselt commented 7 years ago

Check your server logs.

mideuger commented 7 years ago

My bad I forget to check in depth, was thinking the last line was the only thing I can see from the server.

{"reqId":"XiKoFbTQ2myP8xwvXNVM","remoteAddr":"172.18.0.12","app":"core","message":"Trusted domain error. \"172.18.0.12\" tried to access using \"nextcloud\" as host.","level":2,"time":"2017-02-12T21:58:15+00:00","method":"GET","url":"\/index.php\/apps\/news\/api\/v1-2\/cleanup\/before-update","user":"--","version":"11.0.1.2"}

This is caused by trusted domain policy of nextcloud. I'm running nextcloud and the updater in two separate containers using Docker, so the updater is trying to access nextcloud using its container IP address, which is not registered as a trusted domain.

I can quickly fix it running the updater with the FQDN of my nextcloud instance. However it would be better if the requests stayed in the local network area, but I can't register the container IP as a trusted domain since it would change each time the container is recreated.

I close the issue, if someone as an idea on the last matter :)