I am using PHP 5.6.20, PDO (throwing exceptions only), and MySQL 5.6.28 with persistent connections and EVERYTHING is utf8mb4. My entire stack is set up for utf-8 (dsn string settings, connections, database server databases, tables, columns, Apache 2.4.12, PHP, all webpages, CSS ... you name it).
I get the following error message intermittently and it is mystifying and annoying.
Notice: PDO::__construct(): send of 5 bytes failed with errno=32 Broken pipe in file /foo/bar/baz
Assuming a persistent connection is a noninteractive one, the MySQL 5.6 manual (5.1.4 Server System Variables) says the following about the server system variable wait_timeout
.
The number of seconds the server waits for activity on a
noninteractive connection before closing it.
Default: 28800 sec
(28000 sec / 1) * (1 hour / 3600 sec) = 8 hours
Max: 31536000 sec
((31536000 sec / 1) * (1 hr / 3600 sec) * (1 day / 24 hrs) = 365 days
Therefore, check wait_timeout
in your my.cnf
and decide if persistent connections are what you need. Also, you'll have to invest in making your application more robust to account for a persistent connection that has been torn down. Clearly, you do not want your client to come back the next day (having gone home for the night) and say "What the heck?!"