August 30, 2011 at 8:42 pm #13960
I’m attempting to create a script to be as portable as possible and yet still have the capability of running cron jobs. I figured it would be easy enough to imitate a job by making the script send an asynchronous request back to itself, which would then run the job.
It works like this:
1. User, search engine, evil bot visits site.
2. The database is checked for overdue jobs.
3. If one is found, a POST request is sent to the necessary page using fsock or cURL. It doesn’t wait for a reply so the running job doesn’t affect the visitor (the jobs can end up taking a few minutes or more to run).
4. After the job is done, it updates the database with the next scheduled time and a notification that the job is no longer running.
Seems like it would work fine, because I have done it before. But now, after noticing that the jobs weren’t running the way they’re supposed to, I decided to check my logs. They’re filled with mysterious “499″ status codes. 499 doesn’t even exist in the HTTP spec, so I assume it’s some special code delivered by nginx. Google proved useless, simply stating that it’s a result of the client unexpectedly terminating the process.
I can’t help but wondering if this is happening because I’m running nginx on Windows. Anyone have any ideas?August 31, 2011 at 6:31 pm #14873
special code 499 means client closed connection
before nginx response
Perhaps one (or more) of your requests time out? Is there a way to set a larger time interval for a request? You know, like in php.ini you can set the max amount of seconds a script can run?August 31, 2011 at 8:16 pm #14874
I have the request timeout set for 30 seconds, but it’s sending 499 long before then (less than half a second). I suppose a good test case would be to install something like WordPress or Drupal on my server and see if the scheduled jobs in those are giving me 499s.September 2, 2011 at 4:05 pm #14875
So, it looks like even nginx is even sending a 499 error for WP’s cron jobs. Looks like it’s an issue of nginx+Windows and the way Windows handles events, because I know it was working correctly when I did it on nginx+Linux. Shame, I love nginx.September 2, 2011 at 8:12 pm #14876
You could try a Linux VM, maybe? Or does it take up too much space. One of my colleagues said it took up too many resources (he had Win XP) so he couldn’t use it. I didn’t generally have issues with the VM on Win7.
In case you’re interested, I used http://www.virtualbox.org/September 2, 2011 at 8:30 pm #14877
Space isn’t so much the problem in my situation as is CPU and memory. By some miracle my 4-year-old Intel Atom processor (1.6 GHz single core) can handle Dreamweaver, Photoshop, InDesign, Illustrator and 3 different browsers at the same time.
I had a dual-boot of Ubuntu/Windows 7 on this, but it was getting to be such a pain to switch over to Windows just to use Photoshop and Illustrator (Wine apparently doesn’t work with my CS version). It’s too bad, because I really love gedit as an IDE.September 2, 2011 at 9:37 pm #14878
^ oh sorry, I mean to say too much memory. That was my colleague’s issue too, mainly Apache would freeze on him a lot, which in turn caused the VM to freeze as well.
You must be logged in to reply to this topic.