程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Erro 500 / in handle / in handle_request / required 'SEND' - Django ASGI + Gunicorn + Nginx大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决Erro 500 / in handle / in handle_request / required 'SEND' - Django ASGI + Gunicorn + Nginx?

开发过程中遇到Erro 500 / in handle / in handle_request / required 'SEND' - Django ASGI + Gunicorn + Nginx的问题如何解决?下面主要结合日常开发的经验,给出你关于Erro 500 / in handle / in handle_request / required 'SEND' - Django ASGI + Gunicorn + Nginx的解决方法建议,希望对你解决Erro 500 / in handle / in handle_request / required 'SEND' - Django ASGI + Gunicorn + Nginx有所启发或帮助;

我有一个严重的问题,让我损失了几个小时,但没有任何解决办法。在已安装的模块下方:

Package                      Version
---------------------------- ---------
asgiref                      3.3.4
attrs                        20.3.0
autobahn                     21.3.1
automat                      20.2.0
certifi                      2020.12.5
cffi                         1.14.5
chAnnels                     3.0.3
chardet                      4.0.0
constantly                   15.1.0
cryptography                 3.4.7
daphne                       3.0.2
Django                       3.1.7
django-appconf               1.0.4
django-bootstrap-modal-forms 2.1.0
django-compressor            2.4
django-crispy-forms          1.11.2
django-drf-filepond          0.3.0
django-extensions            3.1.2
django-filter                2.4.0
django-mathfilters           1.0.0
django-model-utils           4.1.1
django-pandas                0.6.4
django-redis                 4.12.1
django-stdimage              5.3.0
django-storages              1.11.1
django-Widget-tweaks         1.4.8
djangorestframework          3.12.4
geographiclib                1.50
geopy                        2.1.0
gunicorn                     20.1.0
hyperlink                    21.0.0
IDna                         2.10
importlib-Metadata           3.10.1
incremental                  21.3.0
Markdown                     3.3.4
numpy                        1.20.2
pandas                       1.2.4
Pillow                       8.2.0
pip                          21.0.1
psycopg2                     2.8.6
pyasn1                       0.4.8
pyasn1-modules               0.2.8
pycparser                    2.20
pyhamcrest                   2.0.2
pyOpenSSL                    20.0.1
python-dateutil              2.8.1
pytz                         2021.1
rCSSmin                      1.0.6
redis                        3.5.3
requests                     2.25.1
rJsmin                       1.1.0
service-IDentity             18.1.0
setuptools                   54.1.2
shortuuID                    1.0.1
six                          1.15.0
sqlparse                     0.4.1
Twisted                      21.2.0
txaio                        21.2.1
tyPing-extensions            3.7.4.3
urllib3                      1.26.4
uvloop                       0.15.2
wheel                        0.36.2
zipp                         3.4.1
zope.interface               5.4.0

在“python3 manage.py runserver”或“python3 manage.py runserver 0.0.0.0:8000”上运行服务器时,一切都很完美!但是用gunicorn + Nginx运行系统时,出现如下错误输出:

gunicorn.service - gunicorn daemon
   Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2021-04-15 15:38:31 -03; 16s ago
 Main PID: 2077 (gunicorn)
    Tasks: 4 (limit: 4915)
   Memory: 170.1M
   CGroup: /system.slice/gunicorn.service
           ├─2077 /opt/sistema/venv/bin/python /opt/sistema/venv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock sistema.asgi
           ├─2080 /opt/sistema/venv/bin/python /opt/sistema/venv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock sistema.asgi
           ├─2081 /opt/sistema/venv/bin/python /opt/sistema/venv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock sistema.asgi
           └─2082 /opt/sistema/venv/bin/python /opt/sistema/venv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock sistema.asgi

abr 15 15:38:32 server1 gunicorn[2077]: [2021-04-15 15:38:32 -0300] [2081] [INFO] BooTing worker with pID: 2081
abr 15 15:38:32 server1 gunicorn[2077]: [2021-04-15 15:38:32 -0300] [2082] [INFO] BooTing worker with pID: 2082
abr 15 15:38:46 server1 gunicorn[2077]: [2021-04-15 15:38:46 -0300] [2081] [ERROR] Error handling request /
abr 15 15:38:46 server1 gunicorn[2077]: TraceBACk (most recent call last):
abr 15 15:38:46 server1 gunicorn[2077]:   file "/opt/sistema/venv/lib/python3.7/site-packages/gunicorn/workers/sync.py",line 136,in handle
abr 15 15:38:46 server1 gunicorn[2077]:     self.handle_request(Listener,req,clIEnt,addr)
abr 15 15:38:46 server1 gunicorn[2077]:   file "/opt/sistema/venv/lib/python3.7/site-packages/gunicorn/workers/sync.py",line 179,in handle_request
abr 15 15:38:46 server1 gunicorn[2077]:     respiter = self.wsgi(environ,resp.start_responsE)
abr 15 15:38:46 server1 gunicorn[2077]: TypeError: __call__() missing 1 required positional argument: 'send'
abr 15 15:38:46 server1 gunicorn[2077]:  - - [15/Apr/2021:15:38:46 -0300] "GET / http/1.0" 500 0 "-" "-"
(venv) root@server1:/opt/sistema/sistema# gunicorn --bind 0.0.0.0:8000 sistema.asgi
[2021-04-15 15:39:44 -0300] [2126] [INFO] StarTing gunicorn 20.1.0
[2021-04-15 15:39:44 -0300] [2126] [INFO] Listening at: http://0.0.0.0:8000 (2126)
[2021-04-15 15:39:44 -0300] [2126] [INFO] Using worker: sync
[2021-04-15 15:39:44 -0300] [2129] [INFO] BooTing worker with pID: 2129
^C[2021-04-15 15:39:59 -0300] [2126] [INFO] Handling signal: int
[2021-04-15 15:40:00 -0300] [2129] [INFO] Worker exiTing (pID: 2129)
[2021-04-15 15:40:00 -0300] [2126] [INFO] ShutTing down: Master

setTings.py

import os
from pathlib import Path



BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

SECRET_KEY = 'w(vwss5-t6@((f5umorun6@cxbf#d55@r(*t84d8_5sytd3nuf'

DEBUG = True

ALLOWED_HOSTS = ['*']

INSTALLED_APPS = [
    
    'django.contrib.admin','django.contrib.auth','django.contrib.ContentTypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','django.contrib.sitemaps',#sitemap
    'rest_framework','rest_framework.authtoken','django_redis','website','accounts','chat','django_extensions','chAnnels','compressor','crispy_forms','django_drf_filepond','stdimage','bootstrap_modal_forms','Widget_tweaks','django.contrib.POSTGRes','django_filters','geopy','mathfilters',]



MIDDLEWARE = [
    'django.mIDdleware.security.SecuritymIDdleware','django.contrib.sessions.mIDdleware.SessionMIDdleware','django.mIDdleware.common.CommonMIDdleware','django.mIDdleware.csrf.CsrfVIEwMIDdleware','django.contrib.auth.mIDdleware.AuthenticationMIDdleware','django.contrib.messages.mIDdleware.messageMIDdleware','django.mIDdleware.clickjacking.XFrameOptionsMIDdleware','django.mIDdleware.locale.LocaleMIDdleware',#'deBUG_toolbar.mIDdleware.DeBUGToolbarMIDdleware',]

ROOT_URLconf = 'sistema.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.BACkends.django.DjangoTemplates','Dirs': [os.path.join(BASE_DIR,'templates'),],'APP_Dirs': True,'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.deBUG','django.template.context_processors.request','django.contrib.auth.context_processors.auth','django.contrib.messages.context_processors.messages',},]

Asgi_APPliCATION = "sistema.routIng.application"
Wsgi_APPliCATION = 'sistema.wsgi.application'

CHAnnEL_LAYERS = {
    'default': {
        'BACKEND': 'chAnnels.layers.InMemoryChAnnelLayer'
    }
}

#CACHES = {
#    'default': {
#        'BACKEND': 'django_redis.cache.redisCache',#        'LOCATION': 'redis://127.0.0.1:6379/1',#        'OPTIONS': {
#            'CLIENT_CLASS': 'django_redis.CLIENt.DefaultClIEnt'
#        },#        'KEY_PREFIX': 'django_orm'
#    }
#}

DATABASES = {
    'default': {
        'ENGINE': 'django.db.BACkends.POSTGResql_psycopg2','name': os.environ.get('db_name','dbsistema'),'USER': os.environ.get('DB_USER','psql'),'passworD': os.environ.get('DB_PASS','senhadobancodedados'),'HOST': '127.0.0.1','PORT': '5432','CHARSET': 'UTF8','CONN_MAX_AGE': 600,}
}


AUTH_password_VALIDATORS = [
    {
        'name': 'django.contrib.auth.password_valIDation.UserAttributeSimilarityValIDator',{
        'name': 'django.contrib.auth.password_valIDation.MinimumLengthValIDator',{
        'name': 'django.contrib.auth.password_valIDation.CommonpasswordValIDator',{
        'name': 'django.contrib.auth.password_valIDation.NumericpasswordValIDator',]


LANGUAGE_CODE = 'pt-br'

TIME_ZONE = 'America/Sao_Paulo'



USE_I18N = True

USE_L10N = True

USE_TZ = True


STATICfileS_FINDERS = (
    'django.contrib.staticfiles.finders.fileSystemFinder','django.contrib.staticfiles.finders.appdirectorIEsFinder','compressor.finders.CompressorFinder',)

COMPRESS_ENABLED = DEBUG

STATIC_URL = '/static/'

STATICfileS_Dirs = [
    os.path.join(BASE_DIR,'static'),]

STATIC_ROOT = os.path.join(BASE_DIR,"staticfiles")

SESSION_EXPIRE_AT_BroWSER_CLOSE = false

MEDIA_ROOT = (
  os.path.join(BASE_DIR,"media")
)

MEDIA_URL = '/media/'

DATE_FORMATS = ['%d/%m/%Y']

DATE_input_FORMATS = ['%d/%m/%Y']

CRISPY_TEMPLATE_PACK = 'bootstrap4'

EMAIL_BACKEND = 'django.core.mail.BACkends.console.EmailBACkend'

LOGIN_REDIRECT_URL = '../../../../'

logoUT_REDIRECT_URL = '../../../../'

AUTH_user_R_578_11845@ODEL = 'accounts.Account'

DJANGO_DRF_filePOND_UPLOAD_TMP = os.path.join(BASE_DIR,'media')
DJANGO_DRF_filePOND_file_STORE_PATH = os.path.join(BASE_DIR,'media')


#DEFAulT_auto_FIELD = 'django.db.models.bigautoFIEld'

REST_FRAMEWORK = {
    'DEFAulT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.TokenAuthentication',),'DEFAulT_PERMISSION_CLASSES': (
        'rest_framework.permissions.IsAuthenticated','DEFAulT_PAGINATION_CLASS': 'rest_framework.pagination.PagenumberPagination','PAGE_SIZE': 2,}

TIME_input_FORMATS = [ '%H:%M',]


EMAIL_BACKEND = os.environ.get("EMAIL_BACKEND")
SENDGRID_API_KEY = os.environ.get("SENDGRID_API_KEY")
SENDGRID_SANDBox_MODE_IN_DEBUG = os.environ.get("SENDGRID_SANDBox_MODE_IN_DEBUG")


DATA_UPLOAD_MAX_MEMORY_SIZE = 10000000000000
file_UPLOAD_MAX_MEMORY_SIZE = 52428800000000


admin_ENABLED = false


CORS_ORIGIN_ALLOW_ALL = True

DEBUG_TOolbar_PANELS = [
    'deBUG_toolbar.panels.history.HistoryPanel','deBUG_toolbar.panels.versions.VersionsPanel','deBUG_toolbar.panels.timer.TimerPanel','deBUG_toolbar.panels.setTings.SetTingsPanel','deBUG_toolbar.panels.headers.headersPanel','deBUG_toolbar.panels.request.requestPanel','deBUG_toolbar.panels.sql.sqlPanel','deBUG_toolbar.panels.staticfiles.StaticfilesPanel','deBUG_toolbar.panels.templates.TemplatesPanel','deBUG_toolbar.panels.cache.CachePanel','deBUG_toolbar.panels.signals.SignalsPanel','deBUG_toolbar.panels.logging.LoggingPanel','deBUG_toolbar.panels.redirects.RedirectsPanel','deBUG_toolbar.panels.profiling.ProfilingPanel',]



LOGGING = {
    'version': 1,'disable_exisTing_loggers': false,'handlers': {
        'console': {
            'class': 'logging.StreamHandler','loggers': {
        'django.db.BACkends': {
            'level': 'DEBUG','handlers': ['console'],}
    },}

asgi.py

import os
from chAnnels.routIng import get_default_application

os.environ.setdefault('DJANGO_SETTinGS_MODulE','mercati.setTings')

application = get_default_application()

路由.py

import os
from chAnnels.routIng import ProtocolTypeRouter,URLRouter
from chAnnels.auth import AuthMIDdlewareStack
from chAnnels.http import AsgiHandler
from django.core.asgi import get_asgi_application
from chat import urls


os.environ.setdefault("DJANGO_SETTinGS_MODulE","mercati.setTings")


application = ProtocolTypeRouter({
    "websocket": AuthMIDdlewareStack(
        URLRouter(
            urls.websocket_urlpatterns
        )
    ),})



有人知道问题出在哪里吗?从现在开始,我非常感谢你。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

大佬总结

以上是大佬教程为你收集整理的Erro 500 / in handle / in handle_request / required 'SEND' - Django ASGI + Gunicorn + Nginx全部内容,希望文章能够帮你解决Erro 500 / in handle / in handle_request / required 'SEND' - Django ASGI + Gunicorn + Nginx所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。