Search
 
SCRIPT & CODE EXAMPLE
 

PHP

websocket 2006 MySQL server has gone away

Opened connection from mysql client to the database is not intended to be open for several hours. 
After some time the client disconnects.
Technically, when making a WebSocket request, we can do mysqli::ping - ping the connection to the server or try to reconnect if the connection is lost.

$mysqli = new mysqli("localhost", "my_user", "my_password", "world");

/* check connection */
if ($mysqli->connect_errno) {
    printf("Connect failed: %s
", $mysqli->connect_error);
    exit();
}

/* check if server is alive */
if ($mysqli->ping()) {
    printf ("Our connection is ok!
");
} else {
    printf ("Error: %s
", $mysqli->error);
}

/* close connection */
$mysqli->close();
Comment

PREVIOUS NEXT
Code Example
Php :: php get username from iis 
Php :: /laravel-2020-07-27.log" could not be opened 
Php :: get the last inserted id using laravel eloquent 
Php :: php close session 
Php :: guzzlehttp post json example 
Php :: sort multi array php 
Php :: php 6 digit random number 
Php :: laravel 5.4 forelse 
Php :: select sum in laravel 
Php :: get the charectors inside braces regex php 
Php :: get today date in php 
Php :: laravel send post request from controller 
Php :: view pdf file in a new tab in php 
Php :: laravel dusk run failed tests 
Php :: php unique string 
Php :: get type of variable php 
Php :: how to fetch jQuery in wordpress 
Php :: generate token in php 
Php :: laravel 8 selecet the 2nd to the last record 
Php :: laravel api csrf token disable 
Php :: how to remove public from url in laravel 
Php :: php artisan migrate could not find driver 
Php :: is php the fucking worst 
Php :: php how to rename a file before saving it 
Php :: explode function in laravel 
Php :: laravel tinker add user 
Php :: how to install dompdf in laravel 
Php :: laravel blade auth user 
Php :: boot method laravel life cycle 
Php :: twig ternary 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =