/ qr /协议错误的无效响应:

时间:2022-02-22 07:08:29

Am trying to implement QR code authentication into my project. So this I used "django-qrauth" module. I followed every step mentioned in https://github.com/aruseni/django-qrauth, but am getting the below error.

我试图在我的项目中实现QR码验证。所以我使用了“django-qrauth”模块。我按照https://github.com/aruseni/django-qrauth中提到的每一步操作,但收到以下错误。

------------------ ERROR STARTS ----------------------------------------

------------------错误开始------------------------------ ----------

Environment:


Request Method: GET
Request URL: http://192.168.17.1:1111/qr/

Django Version: 1.6.5
Python Version: 2.7.0
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'registration',
 'qrcode')
Installed Middleware:
('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',
 'registration.middleware.MobileDetectionMiddleware')


Traceback:
File "D:\USERS\Srikanth\Projects\Django Projects\taskman\django\core\handlers\base.py" in get_response
  112.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "D:\USERS\Srikanth\Projects\Django Projects\taskman\django\contrib\auth\decorators.py" in _wrapped_view
  22.                 return view_func(request, *args, **kwargs)
File "D:\USERS\Srikanth\Projects\Django Projects\taskman\qrauth\views.py" in wrapper
  41.         return func(*args, **kwargs)
File "D:\USERS\Srikanth\Projects\Django Projects\taskman\qrauth\views.py" in qr_code_page
  54.         request.user.id
File "D:\USERS\Srikanth\Projects\Django Projects\taskman\redis\client.py" in setex
  918.         return self.execute_command('SETEX', name, time, value)
File "D:\USERS\Srikanth\Projects\Django Projects\taskman\redis\client.py" in execute_command
  461.             return self.parse_response(connection, command_name, **options)
File "D:\USERS\Srikanth\Projects\Django Projects\taskman\redis\client.py" in parse_response
  471.         response = connection.read_response()
File "D:\USERS\Srikanth\Projects\Django Projects\taskman\redis\connection.py" in read_response
  339.             response = self._parser.read_response()
File "D:\USERS\Srikanth\Projects\Django Projects\taskman\redis\connection.py" in read_response
  118.                                   (str(byte), str(response)))

Exception Type: InvalidResponse at /qr/
Exception Value: Protocol Error: <, head
-------------------------------- ERROR ENDS --------------------------------

#settings.py
AUTH_QR_CODE_EXPIRATION_TIME = 600 # Ten minutes

AUTH_QR_CODE_REDIS_KWARGS = {
    "host": "192.168.17.1",
    "port": 1111,
    "db": 0,
}

#urls.py
    urlpatterns = patterns('',
        url(r'^admin/', include(admin.site.urls)),
        url(r'^qr/', include('qrauth.urls')),
    )

Can anyone tell what's happening.

任何人都可以告诉我们发生了什么。

1 个解决方案

#1


It seems that you have configured the same port for the Django server and the Redis server.

您似乎已为Django服务器和Redis服务器配置了相同的端口。

The Django server running on 192.168.17.1 port 1111 as evidenced by the Request URL: http://192.168.17.1:1111/qr/ message in the debug output. Also, the Redis server configuration in settings.py specifies the same hostname and port:

Django服务器运行在192.168.17.1端口1111上,如请求URL所示:调试输出中的http://192.168.17.1:1111/qr/消息。此外,settings.py中的Redis服务器配置指定相同的主机名和端口:

AUTH_QR_CODE_REDIS_KWARGS = {
    "host": "192.168.17.1",
    "port": 1111,
    "db": 0,
}

So Django's redis client is connecting to the Django server, sending a redis request, and then receiving a HTML response which begins with a <head> tag. This is expected as it is the Django server that has been contacted.

所以Django的redis客户端连接到Django服务器,发送redis请求,然后接收以标签开头的HTML响应。这是预期的,因为它是已联系的Django服务器。

You need to change your redis settings to set the port to the one that your redis server is listening on. By default this is port 6379, but you can check in the redis config file.

您需要更改redis设置以将端口设置为redis服务器正在侦听的端口。默认情况下,这是端口6379,但您可以检入redis配置文件。

#1


It seems that you have configured the same port for the Django server and the Redis server.

您似乎已为Django服务器和Redis服务器配置了相同的端口。

The Django server running on 192.168.17.1 port 1111 as evidenced by the Request URL: http://192.168.17.1:1111/qr/ message in the debug output. Also, the Redis server configuration in settings.py specifies the same hostname and port:

Django服务器运行在192.168.17.1端口1111上,如请求URL所示:调试输出中的http://192.168.17.1:1111/qr/消息。此外,settings.py中的Redis服务器配置指定相同的主机名和端口:

AUTH_QR_CODE_REDIS_KWARGS = {
    "host": "192.168.17.1",
    "port": 1111,
    "db": 0,
}

So Django's redis client is connecting to the Django server, sending a redis request, and then receiving a HTML response which begins with a <head> tag. This is expected as it is the Django server that has been contacted.

所以Django的redis客户端连接到Django服务器,发送redis请求,然后接收以标签开头的HTML响应。这是预期的,因为它是已联系的Django服务器。

You need to change your redis settings to set the port to the one that your redis server is listening on. By default this is port 6379, but you can check in the redis config file.

您需要更改redis设置以将端口设置为redis服务器正在侦听的端口。默认情况下,这是端口6379,但您可以检入redis配置文件。