teddziuba / django-sslserver

A SSL-enabled development server for Django
MIT License
736 stars 108 forks source link

AttributeError: 'NoneType' object has no attribute 'split' #74

Open brandon-clair opened 6 years ago

brandon-clair commented 6 years ago

I'm running Python 3.5 and Django 2.0.2.

After installing django-sslserver, I'm seeing an exception whenever there's any sort of POST to my localhost server. It doesn't yet seem to be causing any problems, but any advice would be appreciated.

Here's the traceback:

Traceback (most recent call last):
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 138, in run
    self.finish_response()
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 279, in write
    self._write(data)
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 453, in _write
    result = self.stdout.write(data)
  File "/usr/lib/python3.5/socket.py", line 593, in write
    return self._sock.send(b)
  File "/usr/lib/python3.5/ssl.py", line 861, in send
    return self._sslobj.write(data)
  File "/usr/lib/python3.5/ssl.py", line 586, in write
    return self._sslobj.write(data)
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1844)
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 46760)
Traceback (most recent call last):
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 138, in run
    self.finish_response()
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 279, in write
    self._write(data)
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 453, in _write
    result = self.stdout.write(data)
  File "/usr/lib/python3.5/socket.py", line 593, in write
    return self._sock.send(b)
  File "/usr/lib/python3.5/ssl.py", line 861, in send
    return self._sslobj.write(data)
  File "/usr/lib/python3.5/ssl.py", line 586, in write
    return self._sslobj.write(data)
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1844)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 141, in run
    self.handle_error()
  File "/home/user/git_projects/django/env/lib/python3.5/site-packages/django/core/servers/basehttp.py", line 86, in handle_error
    super().handle_error()
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 368, in handle_error
    self.finish_response()
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 274, in write
    self.send_headers()
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 331, in send_headers
    if not self.origin_server or self.client_is_modern():
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 344, in client_is_modern
    return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/socketserver.py", line 313, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python3.5/socketserver.py", line 341, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python3.5/socketserver.py", line 354, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.5/socketserver.py", line 681, in __init__
    self.handle()
  File "/home/user/git_projects/django/env/lib/python3.5/site-packages/django/core/servers/basehttp.py", line 154, in handle
    handler.run(self.server.get_app())
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 144, in run
    self.close()
  File "/usr/lib/python3.5/wsgiref/simple_server.py", line 36, in close
    self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
----------------------------------------
brandon-clair commented 6 years ago

Also, here's what I have installed in my virtualenv:

Package                  Version  
------------------------ ---------
Babel                    2.5.3    
beautifulsoup4           4.6.0    
certifi                  2018.1.18
chardet                  3.0.4    
defusedxml               0.5.0    
Django                   2.0.2    
django-phonenumber-field 2.0.0    
django-sslserver         0.20     
html5lib                 1.0.1    
idna                     2.6      
oauthlib                 2.0.6    
phonenumberslite         8.9.1    
pip                      9.0.1    
psycopg2-binary          2.7.4    
PyJWT                    1.6.0    
python3-openid           3.1.0    
pytz                     2018.3   
requests                 2.18.4   
requests-oauthlib        0.8.0    
setuptools               38.5.1   
six                      1.11.0   
social-auth-app-django   2.1.0    
social-auth-core         1.7.0    
urllib3                  1.22     
webencodings             0.5.1    
wheel                    0.30.0  
germancollado commented 6 years ago

Hi, same here: Python 3.5.2 / Django 2.0.3

Traceback (most recent call last):
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 138, in run
    self.finish_response()
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 279, in write
    self._write(data)
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 453, in _write
    result = self.stdout.write(data)
  File "/usr/lib/python3.5/socket.py", line 593, in write
    return self._sock.send(b)
  File "/usr/lib/python3.5/ssl.py", line 861, in send
    return self._sslobj.write(data)
  File "/usr/lib/python3.5/ssl.py", line 586, in write
    return self._sslobj.write(data)
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1844)
----------------------------------------
Exception happened during processing of request from ('192.168.30.221', 58560)
Traceback (most recent call last):
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 138, in run
    self.finish_response()
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 279, in write
    self._write(data)
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 453, in _write
    result = self.stdout.write(data)
  File "/usr/lib/python3.5/socket.py", line 593, in write
    return self._sock.send(b)
  File "/usr/lib/python3.5/ssl.py", line 861, in send
    return self._sslobj.write(data)
  File "/usr/lib/python3.5/ssl.py", line 586, in write
    return self._sslobj.write(data)
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1844)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 141, in run
    self.handle_error()
  File "/home/german/.virtualenvs/beta10-api/lib/python3.5/site-packages/django/core/servers/basehttp.py", line 86, in handle_error
    super().handle_error()
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 368, in handle_error
    self.finish_response()
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 274, in write
    self.send_headers()
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 331, in send_headers
    if not self.origin_server or self.client_is_modern():
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 344, in client_is_modern
    return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/socketserver.py", line 313, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python3.5/socketserver.py", line 341, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python3.5/socketserver.py", line 354, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.5/socketserver.py", line 681, in __init__
    self.handle()
  File "/home/german/.virtualenvs/beta10-api/lib/python3.5/site-packages/django/core/servers/basehttp.py", line 154, in handle
    handler.run(self.server.get_app())
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 144, in run
    self.close()
  File "/usr/lib/python3.5/wsgiref/simple_server.py", line 36, in close
    self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
davep commented 6 years ago

I'm currently running into the same issue too with a test application. Has anyone managed to identify the cause of this?

eavive commented 6 years ago

I see same errors with Python 3.5.2 + Django 2.0.3 on Ubuntu 16.04 When using Django 2.0.1 no errors appear.

Though I don't use django-sslserver at all. Ended up here after searching Google for this error output.

I do use: Django==2.0.3 django-extensions==2.0.5 django-filter==1.1.0 django-rest-framework-mongoengine==3.3.1 djangorestframework==3.7.7

gohanko commented 6 years ago

I think this might be an issue with django 2.0 itself, I noticed this error in 3 of my django project.

brandon-clair commented 6 years ago

tl;dr: pip install --force-reinstall requests[security] ...maybe

So I don't use this package anymore, but for those looking for a solution, the exception may be due to additional requirements in the requests package, and could potentially be solved by explicitly installing the requirements. It also seemed to help out over in a similar issue, but forcing a re-installation.

The exception certainly is coming from something outside of django-sslserver itself, so if anyone has success with the above, let us know so we could close this issue, with maybe just an update to requirements.txt.

AntJLopez commented 6 years ago

As suggested, I tried: pip install --force-reinstall requests[security]

I am still experiencing the issue. Everything seems to be working properly, but the command line is flooded with these errors. It happens with every one of my Django projects.

I am using Python 3.7.0 and Django 2.1.

ssokolow commented 6 years ago

Judging by the traceback, this looks like the same error detailed in issue #31.

Note that the AttributeError is the result of a chain of During handling of the above exception, another exception occurred: lines.

Allan-Nava commented 6 years ago

How can I fix this problem?

captbilard commented 5 years ago

Am also having this issue now, and based on google search it seems like its a Django thing. I created a form using ModelForm and when I try to save it to the DB. My console is flooded with the error message. I hope this is fixed soon.

abhishek-malik commented 5 years ago

I'm facing the same issue while working on windows and using firefox browser, whereas application is running fine on Ubuntu. Looks like there is some problem with the firewall processing the http requests. This might help : https://github.com/wagtail/wagtail/issues/4254

aevrisso commented 5 years ago

Hi, i used pip install --force-reinstall requests[security] and this as solved my problem, very thanks. mi version de python es 3.7 64b django 2.1.7 mis modulos son: asn1crypto==0.24.0 atomicwrites==1.3.0 attrs==19.1.0 blessings==1.7 certifi==2019.3.9 cffi==1.12.3 chardet==3.0.4 Click==7.0 colorama==0.4.1 config42==0.3.1 coverage==4.5.3 cryptography==2.7 Django==2.1.7 entrypoints==0.3 fake-useragent==0.1.11 filelock==3.0.12 flake8==3.7.7 future==0.17.1 huepy==0.9.8.1 idna==2.8 importlib-metadata==0.17 instabot==0.26.0 instabot-py==0.4.7 instaloader==4.2.8 itsdangerous==1.1.0 mccabe==0.6.1 more-itertools==7.0.0 mysqlclient==1.4.2.post1 Pillow==6.0.0 pluggy==0.12.0 py==1.8.0 pycodestyle==2.5.0 pycparser==2.19 pyflakes==2.1.1 pyOpenSSL==19.0.0 PySocks==1.6.8 pytest==4.5.0 pytest-cov==2.7.1 pytz==2018.9 PyYAML==5.1 requests==2.22.0 requests-toolbelt==0.9.1 responses==0.10.5 schedule==0.6.0 six==1.12.0 SQLAlchemy==1.3.4 toml==0.10.0 tox==3.12.1 tqdm==4.31.1 urllib3==1.25.3 virtualenv==16.4.3 wcwidth==0.1.7 zipp==0.5.1

The lines come out only once and then they do not come out anymore.

iceman2077 commented 5 years ago

I had the same issue. I solved it by setting DATA_UPLOAD_MAX_NUMBER_FIELDS = 10000 in settings.py Django 2.2

Ontheroad123 commented 4 years ago

i have the same error,but i solve it . I have built virtualenv: python 3.6.0 ,old is 3.6.5 django 2.0.6,old is 2.2

ssokolow commented 4 years ago

@Ontheroad123 Are you saying that you downgraded Python and Django? ...because that's the worst thing you can do. You're testing against a version that you can't use in production because the whole point of newer versions is to fix known security vulnerabilities.

Ontheroad123 commented 4 years ago

@Ontheroad123 Are you saying that you downgraded Python and Django? ...because that's the worst thing you can do. You're testing against a version that you can't use in production because the whole point of newer versions is to fix known security vulnerabilities.

yes, i downgrades python and django,though i don't know real reason

harshacheemakurt commented 4 years ago

I had the same issue. I solved it by setting DATA_UPLOAD_MAX_NUMBER_FIELDS = 10000 in settings.py Django 2.2

is also not working in Django 2.1.15, still facing the issue

artur99 commented 3 years ago

https://github.com/django-helpdesk/django-helpdesk/issues/621 Might be related to this, probably fixed with Python 3.7.4+