回答編集履歴
4
補足
answer
CHANGED
@@ -22,8 +22,12 @@
|
|
22
22
|
|
23
23
|
---
|
24
24
|
2018/02/14追記
|
25
|
-
少し気になって調べてみましたが、[urllib.request.urlopen](https://docs.python.jp/3/library/urllib.request.html)はHTTP 1.1のKeep-Alive接続をサポートしないみたいですね。
|
25
|
+
少し気になって調べてみましたが、[urllib.request.urlopen](https://docs.python.jp/3/library/urllib.request.html)はHTTP 1.1のKeep-Alive接続をサポートしないみたいですね。
|
26
26
|
|
27
|
+
> urllib.request モジュールは HTTP/1.1 を使用し、その HTTP リクエストに Connection:close ヘッダーを含みます。
|
28
|
+
|
29
|
+
よって接続するたびに新規ソケットが生成されるとのこと。
|
30
|
+
|
27
31
|
```Python
|
28
32
|
with urllib.request.urlopen(url, timeout=10) as response:
|
29
33
|
# response ヘッダーを表示
|
3
Connection close
answer
CHANGED
@@ -27,6 +27,7 @@
|
|
27
27
|
```Python
|
28
28
|
with urllib.request.urlopen(url, timeout=10) as response:
|
29
29
|
# response ヘッダーを表示
|
30
|
+
# ('Connection', 'close')が表示されると思います。
|
30
31
|
print(response.getheaders())
|
31
32
|
return response.code
|
32
33
|
```
|
2
追記
answer
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
コード上は問題が無いように見受けられます。
|
1
|
+
~~コード上は問題が無いように見受けられます。~~
|
2
|
+
例外発生時に問題があるみたいなので、訂正線を追加
|
2
3
|
|
3
4
|
> urlopen error [WinError 10055]
|
4
5
|
|
@@ -17,4 +18,15 @@
|
|
17
18
|
■参考情報
|
18
19
|
[Windows ソケットのエラー コード、値、および意味](https://support.microsoft.com/ja-jp/help/819124/windows-sockets-error-codes-values-and-meanings)]
|
19
20
|
|
20
|
-
あとは`netstat -anop tcp 3` でポートが`CLOSE_WAIT`状態になっているのかの確認ぐらいでしょうか。
|
21
|
+
あとは`netstat -anop tcp 3` でポートが`CLOSE_WAIT`状態になっているのかの確認ぐらいでしょうか。
|
22
|
+
|
23
|
+
---
|
24
|
+
2018/02/14追記
|
25
|
+
少し気になって調べてみましたが、[urllib.request.urlopen](https://docs.python.jp/3/library/urllib.request.html)はHTTP 1.1のKeep-Alive接続をサポートしないみたいですね。接続するたびに新規ソケットが生成されるとのこと。
|
26
|
+
|
27
|
+
```Python
|
28
|
+
with urllib.request.urlopen(url, timeout=10) as response:
|
29
|
+
# response ヘッダーを表示
|
30
|
+
print(response.getheaders())
|
31
|
+
return response.code
|
32
|
+
```
|
1
追記
answer
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
> urlopen error [WinError 10055]
|
4
4
|
|
5
|
-
WinSockエラー 10055なので考えられる原因は3点あります。
|
5
|
+
WinSockエラー `10055`なので考えられる原因は3点あります。
|
6
6
|
|
7
|
-
1,MaxUserPortの設定を行っていなく、使用可能なポートが枯渇した。
|
7
|
+
1,`MaxUserPort`の設定を行っていなく、使用可能なポートが枯渇した。
|
8
8
|
■参考情報
|
9
9
|
[5000 を超える番号の TCP ポートから接続しようとすると 'WSAENOBUFS (10055)' エラーが表示される](https://support.microsoft.com/ja-jp/help/196271/when-you-try-to-connect-from-tcp-ports-greater-than-5000-you-receive-t)
|
10
10
|
|
@@ -15,4 +15,6 @@
|
|
15
15
|
64bit OSで試してみてくださいな。
|
16
16
|
|
17
17
|
■参考情報
|
18
|
-
[Windows ソケットのエラー コード、値、および意味](https://support.microsoft.com/ja-jp/help/819124/windows-sockets-error-codes-values-and-meanings)
|
18
|
+
[Windows ソケットのエラー コード、値、および意味](https://support.microsoft.com/ja-jp/help/819124/windows-sockets-error-codes-values-and-meanings)]
|
19
|
+
|
20
|
+
あとは`netstat -anop tcp 3` でポートが`CLOSE_WAIT`状態になっているのかの確認ぐらいでしょうか。
|