hi i have implemented comet(long polling request) base application where my application updates content based on server response
my php code is as below,my application uses zend framework
ini_set('set_time_limit', 300);
//get zend session object
$myNamespace = new Zend_Session_Namespace();
//get zend_auth object
$auth=Zend_Auth::getInstance();
$requestTime=time();
$response=array();
$response["returnvalue"]="invalid";
//check for new event on server for 240 seconds else send response
do{
//call_function return true or false
$query=$this->call_function($auth->getIdentity()->user_id,$auth->getIdentity()->lastViewedTime);
//some code here
if(!$query){
//sleep for some time;
sleep(60);
}else{
//send response to server when something new has occured
$lastViewed=round(microtime(true) * 1000);
$user=$auth->getStorage()->read();
$user->lastViewedTime=$lastViewed;
$auth->getStorage()->write($user);
$response["returnvalue"]="valid";
break;
}
}while(true && (time()-$requestTime)<240);
header("Content-Type: application/json");
echo json_encode($response);exit;
my javascript code is
var counter = {
'poll' : function() {
$.ajax({
type: "GET",
url: '/long-polling',
data:"a=b",
dataType:"json",
async:true,
success:function(response){
counter.update(response);
},
error: function(XMLHttpRequest,textStatus){
alert("This Operation Could not be Completed. Please check your Internet Connection and try Again. If problem persists please contact Support");
}
});
},
'update' : function(json) {
alert(json.data);
counter.poll();
}
};
$(document).ready(function(){
counter.poll();
});
my apache configurations are
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 240
MaxClients 150
MaxRequestsPerChild 4
long polling is working fine,but problem is when browser sends other request to load other elements,images on server,server do not reply/blocks request till 5 mins
any suggetions??
session was my problem thanx ,resolved it by adding Zend_Session::writeClose(true);