質問編集履歴
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,107 +1,45 @@
|
|
1
1
|
### バックエンド(Django)にフロントエンド(Angular)からアクセスしたい。
|
2
2
|
|
3
|
-
|
4
|
-
|
5
3
|
バックエンドにDjango、フロントエンドにAngularを使用してWebアプリの開発をしています。
|
6
|
-
|
7
4
|
Djangoで作成したmodelに対して、Angularからアクセスを試みていますが、下記の通りエラーが発生し接続できません。
|
8
|
-
|
9
5
|
現状、デプロイの段階までは至っておらず、localhostで動作を確認しているところです。
|
10
|
-
|
11
6
|
おそらくキャッシュに関わるエラーなのではないかと思うのですが、恥ずかしながらドキュメンテーションを読んでも理解できません。
|
12
|
-
|
13
7
|
どなたかアドバイスいただくことは出来ないでしょうか。
|
14
|
-
|
15
8
|
何卒よろしくお願いいたします。
|
16
9
|
|
17
10
|
|
18
11
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
12
|
### 発生している問題・エラーメッセージ
|
24
|
-
|
25
13
|
Web UIのConsole上のエラーメッセージ
|
26
|
-
|
27
14
|
```
|
28
|
-
|
29
15
|
HttpErrorResponse {headers: HttpHeaders, status: 500, statusText: "Internal Server Error", url: "http://localhost:ポート番号/ファイルパス", ok: false, …}
|
30
|
-
|
31
16
|
```
|
32
|
-
|
33
|
-
Django側、ターミナル上のエラーメッセージ
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
```
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
django_redis.exceptions.ConnectionInterrupted: Redis ConnectionError: Error 8 connecting to redis:6379. nodename nor servname provided, or not known.
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
During handling of the above exception, another exception occurred:
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
Traceback (most recent call last):
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
redis.exceptions.ConnectionError: Error 8 connecting to redis:6379. nodename nor servname provided, or not known.
|
54
|
-
|
55
|
-
```
|
56
|
-
|
57
17
|
|
58
18
|
|
59
19
|
### 該当のソースコード
|
60
20
|
|
61
|
-
|
62
|
-
|
63
21
|
```Python
|
64
|
-
|
65
22
|
# views.pyファイル
|
66
|
-
|
67
23
|
class クラス名(APIView):
|
68
24
|
|
69
|
-
|
70
|
-
|
71
25
|
def get(self, request):
|
72
|
-
|
73
26
|
変数名 = cache.get('〜〜〜')
|
74
|
-
|
75
27
|
if not 変数名:
|
76
|
-
|
77
28
|
time.sleep(2)
|
78
|
-
|
79
29
|
変数名 = list(リスト.objects.all())
|
80
|
-
|
81
30
|
cache.set('〜〜〜', 変数名, timeout=60 * 30)
|
82
31
|
|
32
|
+
変数名2 = request.query_params.get('変数名2', '')
|
83
33
|
```
|
84
|
-
|
85
|
-
|
86
34
|
|
87
35
|
### 試したこと
|
88
36
|
|
89
|
-
|
90
|
-
|
91
37
|
同様のエラー発生への対処法が下記の通りstackoverflowにも記載があったため試してみましたが、どれも解決には至りませんでした。
|
92
|
-
|
93
38
|
https://stackoverflow.com/questions/22216723/redis-error-8-connecting-localhost6379-nodename-nor-servname-provided-or-not/45622206
|
94
|
-
|
95
|
-
|
96
39
|
|
97
40
|
### 補足情報(FW/ツールのバージョンなど)
|
98
41
|
|
99
|
-
|
100
|
-
|
101
42
|
Python 3.9
|
102
|
-
|
103
43
|
Django 3.2
|
104
|
-
|
105
44
|
SQLite 3
|
106
|
-
|
107
45
|
Angular 12.0.0
|
1
エラーメッセージの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -36,21 +36,7 @@
|
|
36
36
|
|
37
37
|
```
|
38
38
|
|
39
|
-
Internal Server Error: "ファイルパス"
|
40
39
|
|
41
|
-
Traceback (most recent call last):
|
42
|
-
|
43
|
-
File "/usr/local/lib/python3.9/site-packages/django_redis/cache.py", line 27, in _decorator
|
44
|
-
|
45
|
-
return method(self, *args, **kwargs)
|
46
|
-
|
47
|
-
File "/usr/local/lib/python3.9/site-packages/django_redis/cache.py", line 94, in _get
|
48
|
-
|
49
|
-
return self.client.get(key, default=default, version=version, client=client)
|
50
|
-
|
51
|
-
File "/usr/local/lib/python3.9/site-packages/django_redis/client/default.py", line 222, in get
|
52
|
-
|
53
|
-
raise ConnectionInterrupted(connection=client) from e
|
54
40
|
|
55
41
|
django_redis.exceptions.ConnectionInterrupted: Redis ConnectionError: Error 8 connecting to redis:6379. nodename nor servname provided, or not known.
|
56
42
|
|
@@ -62,69 +48,7 @@
|
|
62
48
|
|
63
49
|
Traceback (most recent call last):
|
64
50
|
|
65
|
-
File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
|
66
51
|
|
67
|
-
response = get_response(request)
|
68
|
-
|
69
|
-
File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
|
70
|
-
|
71
|
-
response = wrapped_callback(request, *callback_args, **callback_kwargs)
|
72
|
-
|
73
|
-
File "/usr/local/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
|
74
|
-
|
75
|
-
return view_func(*args, **kwargs)
|
76
|
-
|
77
|
-
File "/usr/local/lib/python3.9/site-packages/django/views/generic/base.py", line 70, in view
|
78
|
-
|
79
|
-
return self.dispatch(request, *args, **kwargs)
|
80
|
-
|
81
|
-
File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
|
82
|
-
|
83
|
-
response = self.handle_exception(exc)
|
84
|
-
|
85
|
-
File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception
|
86
|
-
|
87
|
-
self.raise_uncaught_exception(exc)
|
88
|
-
|
89
|
-
File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
|
90
|
-
|
91
|
-
raise exc
|
92
|
-
|
93
|
-
File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch
|
94
|
-
|
95
|
-
response = handler(request, *args, **kwargs)
|
96
|
-
|
97
|
-
File "ファイルパス/views.py", line 29, in get
|
98
|
-
|
99
|
-
変数名 = cache.get('〜〜〜')
|
100
|
-
|
101
|
-
File "/usr/local/lib/python3.9/site-packages/django_redis/cache.py", line 87, in get
|
102
|
-
|
103
|
-
value = self._get(key, default, version, client)
|
104
|
-
|
105
|
-
File "/usr/local/lib/python3.9/site-packages/django_redis/cache.py", line 34, in _decorator
|
106
|
-
|
107
|
-
raise e.__cause__
|
108
|
-
|
109
|
-
File "/usr/local/lib/python3.9/site-packages/django_redis/client/default.py", line 220, in get
|
110
|
-
|
111
|
-
value = client.get(key)
|
112
|
-
|
113
|
-
File "/usr/local/lib/python3.9/site-packages/redis/client.py", line 1606, in get
|
114
|
-
|
115
|
-
return self.execute_command('GET', name)
|
116
|
-
|
117
|
-
File "/usr/local/lib/python3.9/site-packages/redis/client.py", line 898, in execute_command
|
118
|
-
|
119
|
-
conn = self.connection or pool.get_connection(command_name, **options)
|
120
|
-
|
121
|
-
File "/usr/local/lib/python3.9/site-packages/redis/connection.py", line 1192, in get_connection
|
122
|
-
|
123
|
-
connection.connect()
|
124
|
-
|
125
|
-
File "/usr/local/lib/python3.9/site-packages/redis/connection.py", line 563, in connect
|
126
|
-
|
127
|
-
raise ConnectionError(self._error_message(e))
|
128
52
|
|
129
53
|
redis.exceptions.ConnectionError: Error 8 connecting to redis:6379. nodename nor servname provided, or not known.
|
130
54
|
|
@@ -156,10 +80,6 @@
|
|
156
80
|
|
157
81
|
cache.set('〜〜〜', 変数名, timeout=60 * 30)
|
158
82
|
|
159
|
-
|
160
|
-
|
161
|
-
変数名2 = request.query_params.get('変数名2', '')
|
162
|
-
|
163
83
|
```
|
164
84
|
|
165
85
|
|