LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > PHP > php sense that user has quit downloading

Reply
 
Thread Tools Display Modes
  #1  
Old 07-15-2009, 11:54 PM
kc8yds kc8yds is offline
Member
 
Join Date: Apr 2008
Posts: 35
Default php sense that user has quit downloading

any way for php to sense that the user is no longer downloading a file / connected with litespeed?

if a user leaves a page php will just keep processing and in my application this is a waste as it is a common occurrence
Reply With Quote
  #2  
Old 07-16-2009, 02:05 AM
auser auser is offline
Senior Member
 
Join Date: Mar 2009
Posts: 119
how about php session?
Reply With Quote
  #3  
Old 07-16-2009, 12:59 PM
kc8yds kc8yds is offline
Member
 
Join Date: Apr 2008
Posts: 35
Quote:
Originally Posted by auser View Post
how about php session?
i do not think there would be anyway with a php session

"$ch = curl_init(base64_decode($_GET['url']));
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);"




is the idea i am using (shortened it to make it easy to understand in the forums)


it is downloading and sending to the user a flv file located on youtube servers (directed to people in china/iran/turkey (places youtube is blocked)


when someone starts a video then moves away from the page php will keep running and download the entire file wasting incoming bandwidth and cpu time


if need by i can do fopen -- read 50000 bytes at a time -- check if the user is still connected then transfer the next amount -- but i need a if/else statement to check and see if the person is still connected or not)




this is causing a huge slowdown on the server if say someone only watches a few seconds of the video then moves to the next- -and does this repeatedly -- quickly adds up

Last edited by kc8yds; 07-16-2009 at 01:02 PM..
Reply With Quote
  #4  
Old 07-16-2009, 07:35 PM
auser auser is offline
Senior Member
 
Join Date: Mar 2009
Posts: 119
so it looks you're writing a php script to act as "flv proxy" between youtube and client. out of my knowledge however your request become clear.

I think need know the detail steps how web server(here lsws) steam .flv to client.

I guess flash player(at client side) request range download from web server. for example, download No. 1000 bytes to 2000 bytes of .flv file, No. 2000 to No.3000 bytes...etc. until the end of .flv. if that's the case, you can only request same range download from youtube, not the whole .flv file. No request from the client, no request from your script to youtube server. this will have no problem you described. --- just guess. FYI only.
Reply With Quote
  #5  
Old 07-16-2009, 08:10 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
LSWS want to have PHP run as fast as possible. however, if the result of PHP processing was discarded, it will causes some waste in resource.

There is no good solution on LSWS side, as PHP run out of LSWS process only connected with a socket connection.

I am not sure your code fetch the whole content back then start the play back? or start play back as early as data is available.

If it is the former. you need to change your code, it is too inefficient for large media file.

If it is the later case, you can apply some bandwidth throttling policy in PHP, say, fetch the first xxxKB as fast as it can, then thottle it at certain bandwidth cap like 100KB/s, which is just a little bit faster than bandwidth need to play the video smoothly.

LSWS buffer the response, you cannot rely on LSWS to cap the bandwidth for PHP.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:11 AM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.