I am conecting to a feed using the STOMP protocol in PHP
Because there are not many messages coming from the feed I believe my script thinks I have lost connection and the below error pops out:-
Uncaught exception 'StompException' with message 'Unexpected EOF while reading from socket'
If I can send a heart beat I believe the script will keep running - ie know I'm still there
The code is below. My problem is that I am getting errors. See NEW EDIT below
$channel="VSTP_ALL";
$con=new Stomp($server,$user,$password,array('heart-beat'=>'0,20000'));
if (!$con) {
die('connection failed: ' .stomp_connect_error());
}
$con->subscribe("/topic/".$channel);
if ($con->hasFrame()){
$msg=$con->readFrame();
foreach (json_decode($msg->body) as $event) {
var_dump($event);
}
$con->ack($msg);
}
die ('connection lost:'.time());
?>
EDIT
Have edited above to move/change syntax of array('heart-beat','0,20000') to array('heart-beat'=>'0,20000')
However I now get errors as follows in the foreach line:-
Notice: Trying to get property of non-object in
Warning: Invalid argument supplied for foreach()
and then in the ack($msg) line
Warning: Stomp::ack(): Expects parameter 2 to be a string or a StompFrame object. in