{"id":1853,"date":"2024-02-26T11:23:55","date_gmt":"2024-02-26T02:23:55","guid":{"rendered":"https:\/\/www.rocher.kyoto.jp\/arbr\/?p=1853"},"modified":"2024-03-02T12:15:13","modified_gmt":"2024-03-02T03:15:13","slug":"brokenpipeerror-errno-32-broken-pipe%e8%aa%bf%e6%9f%bb","status":"publish","type":"post","link":"https:\/\/www.rocher.kyoto.jp\/arbr\/?p=1853","title":{"rendered":"BrokenPipeError: [Errno 32] Broken pipe\u8abf\u67fb"},"content":{"rendered":"\n<p>ESP8266(ESP-WROOM-02)\u306e\u5185\u5bb9\u3002ESP-WROOM-32\u3067\u306f\u306a\u3044\u306e\u3067\u6ce8\u610f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8b\u8c61<\/h2>\n\n\n\n<p>esp8266 -&gt; nginx(proxy) -&gt; python(HTTPServer)\u3068\u3044\u3046\u69cb\u6210\u3067\u30b5\u30fc\u30d0\u3078esp\u304b\u3089\u30b5\u30fc\u30d0\u30fc\u3078\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u6295\u3052\u305f\u3068\u3053\u308d\u3001\u304b\u306a\u308a\u306e\u78ba\u7387\u3067\u4ee5\u4e0b\u306e\u30ed\u30b0\u304cpython\u3067\u5410\u304b\u308c\u3066\u3044\u305f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Exception occurred during processing of request from ('127.0.0.1', 48024)\nTraceback (most recent call last):\n  File \"\/usr\/lib\/python3.10\/socketserver.py\", line 316, in _handle_request_noblock\n    self.process_request(request, client_address)\n  File \"\/usr\/lib\/python3.10\/socketserver.py\", line 347, in process_request\n    self.finish_request(request, client_address)\n  File \"\/usr\/lib\/python3.10\/socketserver.py\", line 360, in finish_request\n    self.RequestHandlerClass(request, client_address, self)\n  File \"\/usr\/lib\/python3.10\/socketserver.py\", line 747, in __init__\n    self.handle()\n  File \"\/usr\/lib\/python3.10\/http\/server.py\", line 433, in handle\n    self.handle_one_request()\n  File \"\/usr\/lib\/python3.10\/http\/server.py\", line 421, in handle_one_request\n    method()\n  File \"\/home\/yoshitake\/api\/mail_api.py\", line 26, in do_GET\n    self.wfile.write(response_content)\n  File \"\/usr\/lib\/python3.10\/socketserver.py\", line 826, in write\n    self._sock.sendall(b)\n<strong>BrokenPipeError: [Errno 32] Broken pipe<\/strong><\/pre>\n\n\n\n<p>\u76f4\u63a5\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u306f\u3001python\u304c\u30ea\u30af\u30a8\u30b9\u30c8\u5143\u306b\u66f8\u304d\u3053\u3082\u3046\u3068\u3057\u305f\u3089\u76f8\u624b\u304c\u3059\u3067\u306b\u53d7\u4fe1\u5f85\u3061\u72b6\u614b\u3092\u7d42\u4e86\u3057\u3066\u3044\u308b\u3088\u3046\u306a\u5834\u5408\u306b\u8d77\u304d\u308b\u3084\u3064\u3002esp\u5074\u3067\u306f\u63a5\u7d9a\u3057\u305f\u3082\u306e\u306e\u30d8\u30c3\u30c0\u30fc\u3082\u53d6\u5f97\u305b\u305a\u306b\u3059\u3050\u306b\u7d42\u4e86\u3057\u3066\u3044\u308b\u3002<\/p>\n\n\n\n<p>\u3061\u306a\u307f\u306bnginx\u306eaccess.log\u306b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30b9\u30c6\u30fc\u30bf\u30b9499\u3068\uff08python\u306eHTTPServer\u4ed6\u3067\u4f7f\u308f\u308c\u3066\u3044\u308b\u975e\u6a19\u6e96\u306e\uff09\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u304c\u5148\u306b\u9589\u3058\u305f\u3088\u3068\u3044\u3046\u306e\u304c\u6b8b\u3063\u3066\u3044\u308b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">150.9.94.220 - - [26\/Feb\/2024:11:31:56 +0900] \"GET \/api\/reserve_count HTTP\/1.0\" 499 0 \"-\" \"ESP8266\"<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u76f4\u63a5\u306e\u539f\u56e0\u7b87\u6240<\/h2>\n\n\n\n<p>\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u308besp\u5074\u3067\u30c7\u30fc\u30bf\u306e\u53d7\u4fe1\u5f85\u3061\u3092\u3057\u306a\u304f\u3066\u3059\u3050\u306b\u9589\u3058\u3066\u3044\u308b\u306e\u304c\u76f4\u63a5\u306e\u539f\u56e0<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-dark-gray-background-color has-text-color has-background has-link-color wp-elements-da045e4a2a12e3bf8b4d8632d3981cdf\"><code>BearSSL::WiFiClientSecure client;\nclient-&gt;write(\"GET \");\nclient-&gt;write(path);\nclient-&gt;write(\" HTTP\/1.0\\r\\nHost: \");\nclient-&gt;write(host);\nclient-&gt;write(\"\\r\\nUser-Agent: ESP8266\\r\\n\");\nclient-&gt;write(\"\\r\\n\");\n\/\/\u30d8\u30c3\u30c0\u30fc\u66f8\u304d\u8fbc\u307f\u306e\u5f8c\n\/\/delay(1000);\u3000\u307f\u305f\u3044\u306a\u5f85\u3061\u304c\u306a\u304f\nwhile (client-&gt;available()) { \/\/ \u3059\u3050\u306b\u30c7\u30fc\u30bf\u6709\u7121\u3092\u78ba\u8a8d\u3057\u3001\u304a\u305d\u3089\u304f\u30d1\u30a4\u30bd\u30f3\u5074\u306e\u6e96\u5099\u304c\u3067\u304d\u305a\u306b\n    char c = client-&gt;read();\n    Serial.write(c);\n}\nclient-&gt;stop();\/\/ \u7d42\u4e86\u3057\u3066\u3044\u308b<\/code><\/pre>\n\n\n\n<p>delay(1000);\u3068\u304b\u3092\u5165\u308c\u305f\u3089\u3068\u308a\u3042\u3048\u305a\u52d5\u304f\u3002<\/p>\n\n\n\n<p>\u3068\u306f\u3044\u3048\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u3063\u305f\u306e\u3061\u306b\u30c7\u30fc\u30bf\u53d7\u4fe1\u5f8c\u306e\u7d42\u4e86\u4fe1\u53f7\u7684\u306a\u3082\u306e\u3092\u307f\u305f\u3089\u307e\u305f\u306f\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u3067\u30af\u30ed\u30fc\u30ba\u306e\u65b9\u304c\u3088\u3055\u305d\u3046\u3002<\/p>\n\n\n\n<p>\u307e\u305f\u3001\u540c\u3058\u63a5\u7d9a\u65b9\u5f0f\u3067self-signed.badssl.com\u306b\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u308b\u3068\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u304d\u3061\u3093\u3068\u53d6\u5f97\u3067\u304d\u3066\u3044\u308b\u306e\u3067\u30b5\u30fc\u30d0\u30b5\u30a4\u30c9\u306b\u3082\u4f55\u304b\u6539\u5584\u70b9\u304c\u3042\u308a\u305d\u3046\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6839\u672c\u89e3\u6c7a<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30b5\u30a4\u30c9(ESP8266)<\/h3>\n\n\n\n<p><s>\u53d6\u308a\u6025\u304eavailable()\u3067\u306f\u63a5\u7d9a\u3067\u304d\u305f\u304b\u3057\u304b\u78ba\u8a8d\u3057\u3066\u3044\u306a\u3044\u3002<\/s>\u3000WiFiServerSecureBearSSL.cpp\uff08\u30b5\u30fc\u30d0\u306e\u65b9\uff09\u3092\u9593\u9055\u3048\u3066\u307f\u3066\u3044\u305f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-dark-gray-background-color has-text-color has-background has-link-color wp-elements-e7f60efc80552b1bf1d514a92c18a73c\"><code><s>\/\/ Return a client if there's an available connection waiting.  If one is returned,\n\/\/ then any validation (i.e. client cert checking) will have succeeded.\nWiFiClientSecure WiFiServerSecure::available(uint8_t* status) {<\/s><\/code><\/pre>\n\n\n\n<p>\u6539\u3081\u3066<a href=\"https:\/\/github.com\/esp8266\/Arduino\/blob\/master\/libraries\/ESP8266WiFi\/src\/WiFiClientSecureBearSSL.cpp#L420\">WiFiClientSecureBearSSL.cpp<\/a>\u78ba\u8a8d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-dark-gray-background-color has-text-color has-background has-link-color wp-elements-787b81df1ad2e88c525b0cdd90ee10d7\"><code>int WiFiClientSecureCtx::_pollRecvBuffer() {\n  if (_recvapp_buf) {\n    return _recvapp_len;  \/\/ Anything from last call?\n  }\n  _recvapp_buf = nullptr;\n  _recvapp_len = 0;\n  if (!ctx_present() || _run_until(BR_SSL_RECVAPP, false) &lt; 0) {\n    return 0;\n  }\n  int st = br_ssl_engine_current_state(_eng);\n  if (st == BR_SSL_CLOSED) {\n    return 0;  \/\/ Nothing leftover, SSL is closed\n  }\n  <strong>if (st &amp; BR_SSL_RECVAPP) {<\/strong>\n    _recvapp_buf = br_ssl_engine_recvapp_buf(_eng, &amp;_recvapp_len);\n    return _recvapp_len;\n  }\n\n  return 0;\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\u5b57\u9762\u3067\u898b\u308b\u9650\u308a\u306a\u3093\u304b\u5165\u3063\u3066\u305f\u30890\u4ee5\u5916\u304c\u5165\u3063\u3066\u3001\u306a\u306b\u3082\u5165\u3063\u3066\u3044\u306a\u3044\u3068\u30b5\u30fc\u30d0\u5074\u304c\u6e96\u5099\u4e2d\u3067\u3082\u4e00\u756a\u4e0b\u306b\u5165\u3063\u30660\u304c\u304f\u308b\u3063\u307d\u3044\u3002\u3060\u3044\u3076\u4e2d\u306e\u65b9\u306b\u66f8\u3044\u3066\u3042\u308b\u306e\u3067\u5185\u90e8\u30c7\u30fc\u30bf\u3092\u898b\u308b\u3068\u8272\u3005\u591a\u5909\u305d\u3046\u306a\u306e\u3067\u6700\u521d\u306e\u30c7\u30fc\u30bf\u6765\u308b\u304b\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u307e\u3067\u306e\u5f85\u3061\u51e6\u7406\u3092\u5165\u308c\u308b\u306e\u304c\u3088\u3055\u305d\u3046\u3002\u65ad\u7d9a\u7684\u306b\u30c7\u30fc\u30bf\u304c\u304f\u308b\u306a\u3089\u3061\u3083\u3093\u3068\u7d42\u7aef\u51e6\u7406\u3092\u898b\u305f\u65b9\u304c\u3088\u3044\u304b\u3082\u3002\n\n\u672c\u4f53\u304b\u3089\u3001\u66f8\u304d\u51fa\u3057\u30e1\u30bd\u30c3\u30c9\u547c\u3073\u51fa\u3057\u3002<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code has-white-color has-dark-gray-background-color has-text-color has-background has-link-color wp-elements-2e55b586cbc726a3587030766a4c6f70\"><code>  client-&gt;write(\"\\r\\n\"); \/\/\u30ea\u30af\u30a8\u30b9\u30c8\u66f8\u304d\u8fbc\u307f\u306e\u6700\u7d42\u884c\n\n  writeData(client); \/\/\u6642\u9593\u5f85\u3061\u3064\u3064\u66f8\u304d\u51fa\u3057\u30e1\u30bd\u30c3\u30c9\u547c\u3073\u51fa\u3057\n\n  client-&gt;stop();\/\/ \u5207\u65ad<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code has-white-color has-dark-gray-background-color has-text-color has-background has-link-color wp-elements-042ad69ee26b2650dc330f0439e7f4de\"><code>void writeData(BearSSL::WiFiClientSecure *client) {\n  uint32_t timeout = millis() + 5000;\n\n  while (!client-&gt;available()) {\n    if (millis() &gt; timeout) return;\n    yield();\n  }\n\n  while (client-&gt;available()) {\n    char c = client-&gt;read();\n    Serial.write(c);\n  }\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u30b5\u30fc\u30d0\u30b5\u30a4\u30c9(nginx+python\u306eHTTPServer)<\/h2>\n\n\n\n<p>\u3053\u3061\u3089\u306f\u5358\u7d14\u306b\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u65e9\u304f\u8fd4\u308a\u3060\u3059\u304b\u3069\u3046\u304b\u3067\u9055\u3044\u304c\u51fa\u3066\u3044\u305f\u3063\u307d\u3044\u3002\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u65e9\u3044\u3068\u3044\u3046\u7406\u7531\u3060\u3063\u305f\u5834\u5408\u306f\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u306e\u51e6\u7406\u3067\u89e3\u6c7a\u3059\u3079\u304d\u8a71\u306a\u306e\u3067\u6df1\u304f\u8ffd\u308f\u306a\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ESP8266(ESP-WROOM-02)\u306e\u5185\u5bb9\u3002ESP-WROOM-32\u3067\u306f\u306a\u3044\u306e\u3067\u6ce8\u610f\u3002 \u4e8b\u8c61 esp8266 -&gt; nginx(proxy) -&gt; python(HTTPServer)\u3068\u3044\u3046\u69cb\u6210\u3067\u30b5\u30fc\u30d0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58,117],"tags":[123,132,128],"class_list":["post-1853","post","type-post","status-publish","format-standard","hentry","category-58","category-117","tag-esp","tag-esp-wroom-02","tag-python"],"_links":{"self":[{"href":"https:\/\/www.rocher.kyoto.jp\/arbr\/index.php?rest_route=\/wp\/v2\/posts\/1853","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rocher.kyoto.jp\/arbr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rocher.kyoto.jp\/arbr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rocher.kyoto.jp\/arbr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rocher.kyoto.jp\/arbr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1853"}],"version-history":[{"count":5,"href":"https:\/\/www.rocher.kyoto.jp\/arbr\/index.php?rest_route=\/wp\/v2\/posts\/1853\/revisions"}],"predecessor-version":[{"id":1908,"href":"https:\/\/www.rocher.kyoto.jp\/arbr\/index.php?rest_route=\/wp\/v2\/posts\/1853\/revisions\/1908"}],"wp:attachment":[{"href":"https:\/\/www.rocher.kyoto.jp\/arbr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1853"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rocher.kyoto.jp\/arbr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1853"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rocher.kyoto.jp\/arbr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}