I have a php websocket server based on this one. This websocket server runs on a different apache than the public webserver but on the same physical server so I need a database connection to retrieve userdata. The userdata is fetched by the current session id which is also updated in the database when a user loggs in. Now, if I run my websocket server it works perfect but after a decent time (can't say a timespan) the result stays empty. I checked the dataset.
The querystring is up to date and the correct session id is in the database which should return the desired row but the result stays empty. If I kill the process and run this websocket server, it will work for the time being but after a while the result is empty again.
This is my websocketserver.php simplified:
set_time_limit(0);
require 'class.PHPWebSocket.php';
$db1 = mysql_connect( 'localhost', 'dev', 'xxxxxxxx' );
mysql_select_db('cb_dev',$db1);
function wsOnMessage($clientID, $message, $messageLength, $binary) {
global $Server;
$sessionid = "/*just imagine a session id here*/";
$result = mysql_query("SELECT username, id FROM users WHERE sessionid = '$sessionid'");
$row = mysql_fetch_row($result);
}
function wsOnOpen($clientID) {
//
}
function wsOnClose($clientID, $status) {
//
}
$Server = new PHPWebSocket();
$Server->bind('message', 'wsOnMessage');
$Server->bind('open', 'wsOnOpen');
$Server->bind('close', 'wsOnClose');
$Server->wsStartServer('0.0.0.0', 9010);
Note: The used session id is served correctly so this is not the problem.