Trefo / agdss

decision support system for robotic sampling in precision agriculture
Apache License 2.0
14 stars 8 forks source link

When not using container IP: urllib.error.URLError, Cannot assign requested address> #44

Open darknight-007 opened 6 years ago

darknight-007 commented 6 years ago

eb_1 | Internal Server Error: /webclient/get_overlayed_combined_image/4 web_1 | Traceback (most recent call last): web_1 | File "/usr/local/lib/python3.6/urllib/request.py", line 1318, in do_open web_1 | encode_chunked=req.has_header('Transfer-encoding')) web_1 | File "/usr/local/lib/python3.6/http/client.py", line 1239, in request web_1 | self._send_request(method, url, body, headers, encode_chunked) web_1 | File "/usr/local/lib/python3.6/http/client.py", line 1285, in _send_request web_1 | self.endheaders(body, encode_chunked=encode_chunked) web_1 | File "/usr/local/lib/python3.6/http/client.py", line 1234, in endheaders web_1 | self._send_output(message_body, encode_chunked=encode_chunked) web_1 | File "/usr/local/lib/python3.6/http/client.py", line 1026, in _send_output web_1 | self.send(msg) web_1 | File "/usr/local/lib/python3.6/http/client.py", line 964, in send web_1 | self.connect() web_1 | File "/usr/local/lib/python3.6/http/client.py", line 936, in connect web_1 | (self.host,self.port), self.timeout, self.source_address) web_1 | File "/usr/local/lib/python3.6/socket.py", line 724, in create_connection web_1 | raise err web_1 | File "/usr/local/lib/python3.6/socket.py", line 713, in create_connection web_1 | sock.connect(sa) web_1 | OSError: [Errno 99] Cannot assign requested address web_1 | web_1 | During handling of the above exception, another exception occurred: web_1 | web_1 | Traceback (most recent call last): web_1 | File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner web_1 | response = get_response(request) web_1 | File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 128, in _get_response web_1 | response = self.process_exception_by_middleware(e, request) web_1 | File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response web_1 | response = wrapped_callback(request, *callback_args, *callback_kwargs) web_1 | File "/usr/local/lib/python3.6/site-packages/django/views/decorators/http.py", line 40, in inner web_1 | return func(request, args, *kwargs) web_1 | File "/app/webclient/views.py", line 532, in get_overlayed_combined_image web_1 | background = PILImage.open(urlopen(url)) web_1 | File "/usr/local/lib/python3.6/urllib/request.py", line 223, in urlopen web_1 | return opener.open(url, data, timeout) web_1 | File "/usr/local/lib/python3.6/urllib/request.py", line 526, in open web_1 | response = self._open(req, data) web_1 | File "/usr/local/lib/python3.6/urllib/request.py", line 544, in _open web_1 | '_open', req) web_1 | File "/usr/local/lib/python3.6/urllib/request.py", line 504, in _call_chain web_1 | result = func(args) web_1 | File "/usr/local/lib/python3.6/urllib/request.py", line 1346, in http_open web_1 | return self.do_open(http.client.HTTPConnection, req) web_1 | File "/usr/local/lib/python3.6/urllib/request.py", line 1320, in do_open web_1 | raise URLError(err) web_1 | urllib.error.URLError: <urlopen error [Errno 99] Cannot assign requested address> web_1 | [10/Jun/2018 16:31:17] "GET /webclient/get_overlayed_combined_image/4 HTTP/1.1" 500 142665

darknight-007 commented 6 years ago

Using the IP assigned to the host instead of loopback or 0.0.0.0 seems to resolve this issue.

darknight-007 commented 6 years ago

using host IP doesn't solve the issue. @cassiemai and I tested on digitalocean node

darknight-007 commented 6 years ago

Sometimes manifests as following (likely because the foreground image blob is somehow corrupted?). I initially thought this was a CSRF issue, but didn't see any evidence of that. The other cause for this overall issue could be how admin view is configured. Could it simply be an urls.py issue?

Environment:

Request Method: GET Request URL: http://162.243.207.90:8000/webclient/get_overlayed_combined_image/4

Django Version: 2.0.6 Python Version: 3.6.5 Installed Applications: ['webclient.apps.WebclientConfig', 'django.contrib.admin.apps.SimpleAdminConfig', 'adminplus', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django_extensions'] Installed Middleware: ['django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback:

File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner

  1. response = get_response(request)

File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response

  1. response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response

  1. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python3.6/site-packages/django/views/decorators/csrf.py" in wrapped_view

  1. return view_func(*args, **kwargs)

File "/app/webclient/views.py" in get_overlayed_combined_image

  1. background.paste(foreground, (0, 0), foreground)

File "/usr/local/lib/python3.6/site-packages/PIL/Image.py" in paste

  1. self.im.paste(im, box, mask.im)

Exception Type: ValueError at /webclient/get_overlayed_combined_image/4 Exception Value: bad transparency mask

CassieMai commented 6 years ago

Hello, @darknight-007 . How do you debug in django? I would like to look over intermediate variables in agdss/webclient/view.py. Do you have any idea?