{"id":26416,"date":"2024-11-24T16:26:07","date_gmt":"2024-11-24T08:26:07","guid":{"rendered":"https:\/\/fwq.ai\/blog\/26416\/"},"modified":"2024-11-24T16:26:07","modified_gmt":"2024-11-24T08:26:07","slug":"php-%e8%84%9a%e6%9c%ac%e5%9b%a0-broken-pipe-%e9%94%99%e8%af%af%e8%80%8c%e4%b8%ad%e6%ad%a2%ef%bc%9a%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3mysqli_query-send-of-309-bytes-failed-with-errno32-br-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/26416\/","title":{"rendered":"PHP \u811a\u672c\u56e0 Broken Pipe \u9519\u8bef\u800c\u4e2d\u6b62\uff1a\u5982\u4f55\u89e3\u51b3\u201cmysqli_query(): send of 309 bytes failed with errno=32 Broken pipe\u201d\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173094248962868.jpg\" class=\"aligncenter\" title=\"PHP \u811a\u672c\u56e0 Broken Pipe \u9519\u8bef\u800c\u4e2d\u6b62\uff1a\u5982\u4f55\u89e3\u51b3\u201cmysqli_query(): send of 309 bytes failed with errno=32 Broken pipe\u201d\uff1f\u63d2\u56fe\" alt=\"PHP \u811a\u672c\u56e0 Broken Pipe \u9519\u8bef\u800c\u4e2d\u6b62\uff1a\u5982\u4f55\u89e3\u51b3\u201cmysqli_query(): send of 309 bytes failed with errno=32 Broken pipe\u201d\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>php \u811a\u672c\u56e0 broken pipe \u9519\u8bef\u800c\u4e2d\u6b62<\/strong><\/p>\n<p>\u4f60\u66fe\u9047\u5230\u8fc7\u7c7b\u4f3c\u4e8e\u201ci_query(): send of 309 bytes fled with errno=32 broken pipe\u201d\u8fd9\u6837\u7684\u9519\u8bef\u5417\uff1f\u8fd9\u4e2a\u95ee\u9898\u4ee4\u4eba\u70e6\u607c\uff0c\u5e76\u4e14\u4f1a\u4e2d\u65ad\u4f60\u7684\u811a\u672c\u3002<\/p>\n<p><strong>\u4e3a\u4ec0\u4e48\u4f1a\u53d1\u751f broken pipe \u9519\u8bef\uff1f<\/strong><\/p>\n<p>broken pipe \u9519\u8bef\u901a\u5e38\u662f\u56e0\u4e3a php \u811a\u672c\u4e0e mysql \u670d\u52a1\u5668\u4e4b\u95f4\u7684\u8fde\u63a5\u7531\u4e8e\u957f\u65f6\u95f4\u672a\u64cd\u4f5c\u800c\u88ab\u5173\u95ed\u3002\u5f53\u811a\u672c\u518d\u6b21\u5c1d\u8bd5\u901a\u8fc7\u5df2\u5173\u95ed\u7684\u8fde\u63a5\u6267\u884c\u67e5\u8be2\u65f6\uff0c\u5c31\u4f1a\u5bfc\u81f4\u9519\u8bef\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p><strong>\u5982\u4f55\u4fee\u590d broken pipe \u9519\u8bef\uff1f<\/strong><\/p>\n<p>\u8981\u89e3\u51b3 broken pipe \u9519\u8bef\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<ol>\n<li> <strong>\u68c0\u67e5 mysql \u670d\u52a1\u5668\u7684 wait_timeout \u53c2\u6570\u3002<\/strong>\u8fd9\u4e2a\u53c2\u6570\u5b9a\u4e49\u4e86\u975e\u4ea4\u4e92\u8fde\u63a5\u5728\u6ca1\u6709\u6d3b\u52a8\u540e\u4f1a\u88ab\u5173\u95ed\u7684\u65f6\u957f\u3002\u6839\u636e\u9700\u8981\u5c06\u5b83\u8bbe\u4e3a\u4e00\u4e2a\u8f83\u5927\u7684\u503c\uff0c\u4f8b\u5982\uff1a<\/li>\n<\/ol>\n<pre>set global wait_timeout = 1000;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li> <strong>\u5728\u811a\u672c\u4e2d\u4f7f\u7528 mysqli_ping() \u51fd\u6570\u3002<\/strong>\u8fd9\u4e2a\u51fd\u6570\u7528\u4e8e\u68c0\u67e5\u8fde\u63a5\u662f\u5426\u6d3b\u52a8\u3002\u5982\u679c\u8fde\u63a5\u5df2\u7ecf\u65ad\u5f00\uff0c\u4f60\u53ef\u4ee5\u91cd\u65b0\u8fde\u63a5\uff1a<\/li>\n<\/ol>\n<pre>if (!mysqli_ping($conn)) {\n    \/\/ \u65ad\u5f00\u8fde\u63a5\n    mysqli_close($conn);\n\n    \/\/ \u91cd\u65b0\u8fde\u63a5\n    $conn = mysqli_connect($host, $user, $password, $database);\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fPHP \u811a\u672c\u56e0 Broken Pipe \u9519\u8bef\u800c\u4e2d\u6b62\uff1a\u5982\u4f55\u89e3\u51b3\u201ci_query(): send of 309 bytes fled with errno=32 Broken pipe\u201d\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>php \u811a\u672c\u56e0 broken pipe \u9519\u8bef\u800c\u4e2d\u6b62 \u4f60\u66fe\u9047\u5230\u8fc7\u7c7b\u4f3c\u4e8e\u201ci_query(): send of 309 bytes fled with errno=32 broken pipe\u201d\u8fd9\u6837\u7684\u9519\u8bef\u5417\uff1f\u8fd9\u4e2a\u95ee\u9898\u4ee4\u4eba\u70e6\u607c\uff0c\u5e76\u4e14\u4f1a\u4e2d\u65ad\u4f60\u7684\u811a\u672c\u3002 \u4e3a\u4ec0\u4e48\u4f1a\u53d1\u751f broken pipe \u9519\u8bef\uff1f broken pipe \u9519\u8bef\u901a\u5e38\u662f\u56e0\u4e3a php \u811a\u672c\u4e0e mysql \u670d\u52a1\u5668\u4e4b\u95f4\u7684\u8fde\u63a5\u7531\u4e8e\u957f\u65f6\u95f4\u672a\u64cd\u4f5c\u800c\u88ab\u5173\u95ed\u3002\u5f53\u811a\u672c\u518d\u6b21\u5c1d\u8bd5\u901a\u8fc7\u5df2\u5173\u95ed\u7684\u8fde\u63a5\u6267\u884c\u67e5\u8be2\u65f6\uff0c\u5c31\u4f1a\u5bfc\u81f4\u9519\u8bef\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u5982\u4f55\u4fee\u590d broken pipe \u9519\u8bef\uff1f \u8981\u89e3\u51b3 broken pipe \u9519\u8bef\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u4e0b\u65b9\u6cd5\uff1a \u68c0\u67e5 mysql \u670d\u52a1\u5668\u7684 wait_timeout \u53c2\u6570\u3002\u8fd9\u4e2a\u53c2\u6570\u5b9a\u4e49\u4e86\u975e\u4ea4\u4e92\u8fde\u63a5\u5728\u6ca1\u6709\u6d3b\u52a8\u540e\u4f1a\u88ab\u5173\u95ed\u7684\u65f6\u957f\u3002\u6839\u636e\u9700\u8981\u5c06\u5b83\u8bbe\u4e3a\u4e00\u4e2a\u8f83\u5927\u7684\u503c\uff0c\u4f8b\u5982\uff1a set global wait_timeout = 1000; \u767b\u5f55\u540e\u590d\u5236 \u5728\u811a\u672c\u4e2d\u4f7f\u7528 mysqli_ping() \u51fd\u6570\u3002\u8fd9\u4e2a\u51fd\u6570\u7528\u4e8e\u68c0\u67e5\u8fde\u63a5\u662f\u5426\u6d3b\u52a8\u3002\u5982\u679c\u8fde\u63a5\u5df2\u7ecf\u65ad\u5f00\uff0c\u4f60\u53ef\u4ee5\u91cd\u65b0\u8fde\u63a5\uff1a if (!mysqli_ping($conn)) { \/\/ \u65ad\u5f00\u8fde\u63a5 mysqli_close($conn); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-26416","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=26416"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26416\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=26416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=26416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=26416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}