Playing do not start and no error if trying to play a track from federation (down instance)
Probably related to #412 (closed) and #415 (closed).
When trying to play a track from a federated instance. If the instance is down API return a 500 error. On server side the exception is :
2018-09-22 06:43:40,951 ERROR Internal Server Error: /api/v1/trackfiles/3155/serve/
Traceback (most recent call last):
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/urllib3/connection.py", line 171, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/urllib3/util/connection.py", line 79, in create_connection
raise err
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/urllib3/util/connection.py", line 69, in create_connection
sock.connect(sa)
socket.timeout: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 849, in _validate_conn
conn.connect()
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/urllib3/connection.py", line 314, in connect
conn = self._new_conn()
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/urllib3/connection.py", line 176, in _new_conn
(self.host, self.timeout))
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.VerifiedHTTPSConnection object at 0x810d0d9b0>, 'Connection to funkwhale.duckdns.org timed out. (connect timeout=20)')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/requests/adapters.py", line 445, in send
timeout=timeout
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/urllib3/util/retry.py", line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='funkwhale.duckdns.org', port=443): Max retries exceeded with url: /api/v1/trackfiles/11487/serve/ (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x810d0d9b0>, 'Connection to funkwhale.duckdns.org timed out. (connect timeout=20)'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/django/core/handlers/base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.6/contextlib.py", line 52, in inner
return func(*args, **kwds)
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/rest_framework/viewsets.py", line 95, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/rest_framework/views.py", line 494, in dispatch
response = self.handle_exception(exc)
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/rest_framework/views.py", line 454, in handle_exception
self.raise_uncaught_exception(exc)
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/rest_framework/views.py", line 491, in dispatch
response = handler(request, *args, **kwargs)
File "./funkwhale_api/music/views.py", line 300, in serve
return handle_serve(queryset.get(pk=kwargs["pk"]))
File "./funkwhale_api/music/views.py", line 253, in handle_serve
library_track.download_audio()
File "./funkwhale_api/federation/models.py", line 189, in download_audio
headers={"Content-Type": "application/activity+json"},
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/requests/sessions.py", line 525, in get
return self.request('GET', url, **kwargs)
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/requests/sessions.py", line 512, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/requests/sessions.py", line 622, in send
r = adapter.send(request, **kwargs)
File "/usr/local/www/funkwhale/virtualenv/lib/python3.6/site-packages/requests/adapters.py", line 501, in send
raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='funkwhale.duckdns.org', port=443): Max retries exceeded with url: /api/v1/trackfiles/11487/serve/ (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x810d0d9b0>, 'Connection to funkwhale.duckdns.org timed out. (connect timeout=20)'))