django channels redis集群 websocket频繁断连

背景

django channels websocket频繁断连,具体表现为握手后立刻断开。排除前端ws的请求问题,排除代码问题,排除redis集群问题,排除django的settings问题

排查发现

python manage.py shell,使用channel_layer发现,能够向redis集群发送,但是读取不了,并且发送的数据在redis中也没有发现。

解决方案

方案一:

依赖库版本不匹配:

一套可使用的版本:

  • django=4.1.3
  • daphne=4.0.0
  • django-redis=5.2.0
  • channels=4.0.0
  • channels-redis=4.0.0

方案二:

重装整个python虚拟环境从anaconda创建——我的是python3.8
以下是一套可用的requirements:

aiohttp==3.8.3
aiosignal==1.2.0
amqp==5.1.1
asgiref==3.5.2
asttokens==2.2.0
async-timeout==4.0.2
attrs==22.1.0
autobahn==22.12.1
Automat==22.10.0
autopep8==2.0.0
backcall==0.2.0
backports.zoneinfo==0.2.1
bandit==1.7.4
bcrypt==4.0.1
billiard==3.6.4.0
celery==5.2.7
certifi==2022.9.24
cffi==1.15.1
channels==4.0.0
channels-redis==4.0.0
charset-normalizer==2.1.1
click==8.1.3
click-didyoumean==0.3.0
click-plugins==1.1.1
click-repl==0.2.0
colorama==0.4.6
comm==0.1.2
constantly==15.1.0
coreapi==2.3.3
coreschema==0.0.4
cryptography==38.0.4
daphne==4.0.0
debugpy==1.6.6
decorator==5.1.1
Deprecated==1.2.13
Django==4.1.3
django-extensions==3.2.1
django-redis==5.2.0
djangorestframework==3.14.0
dnspython==2.2.1
drf-yasg==1.21.4
et-xmlfile==1.1.0
eventlet==0.33.2
exceptiongroup==1.0.4
executing==1.2.0
fabric==2.7.1
flower==1.2.0
frozenlist==1.3.1
gevent==22.10.2
gitdb==4.0.10
GitPython==3.1.31
greenlet==2.0.1
gunicorn==20.1.0
h11==0.14.0
hiredis==2.2.2
humanize==4.4.0
hyperlink==21.0.0
idna==3.4
importlib-metadata==6.0.0
importlib-resources==5.10.0
incremental==22.10.0
inflection==0.5.1
iniconfig==1.1.1
invoke==1.7.3
ipykernel==6.21.2
ipython==8.7.0
itypes==1.2.0
jedi==0.18.2
Jinja2==3.1.2
jsonpath==0.82
jsonschema==4.17.0
jupyter_client==8.0.3
jupyter_core==5.2.0
kombu==5.2.4
MarkupSafe==2.1.1
matplotlib-inline==0.1.6
msgpack==1.0.5
msgpack-python==0.5.6
multidict==6.0.2
mysqlclient==2.1.1
nest-asyncio==1.5.6
numpy==1.23.4
openpyxl==3.0.10
packaging==21.3
pandas==1.5.1
paramiko==2.12.0
parso==0.8.3
pathlib2==2.3.7.post1
pbr==5.11.1
pexpect==4.8.0
pickleshare==0.7.5
Pillow==9.4.0
pkgutil_resolve_name==1.3.10
platformdirs==3.0.0
pluggy==1.0.0
prometheus-client==0.15.0
prompt-toolkit==3.0.32
psutil==5.9.4
ptyprocess==0.7.0
pure-eval==0.2.2
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycodestyle==2.9.1
pycparser==2.21
Pygments==2.13.0
PyJWT==2.6.0
PyMySQL==1.0.2
PyNaCl==1.5.0
pyOpenSSL==22.1.0
pyparsing==3.0.9
pyrsistent==0.19.1
pytest==7.2.0
python-dateutil==2.8.2
pytz==2022.6
PyYAML==6.0
pyzmq==25.0.0
qrcode==7.3.1
redis==4.5.2
requests==2.28.1
ruamel.yaml==0.17.21
ruamel.yaml.clib==0.2.7
service-identity==21.1.0
six==1.16.0
smmap==5.0.0
sqlparse==0.4.3
stack-data==0.6.2
stevedore==5.0.0
tomli==2.0.1
tornado==6.2
traitlets==5.6.0
Twisted==22.10.0
txaio==22.2.1
typing_extensions==4.4.0
tzdata==2022.6
uritemplate==4.1.1
urllib3==1.26.12
uvicorn==0.20.0

vine==5.0.0
wcwidth==0.2.5
wrapt==1.14.1
yarl==1.8.1
zipp==3.10.0
zope.event==4.5.0
zope.interface==5.5.2
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值