2009/7/8 Yoann Roman <[email protected]>: > > I'm using Pylons 0.9.6.2 on Apache 2.2.10 with mod_wsgi 2.3 in > embedded mode on XP SP2. > > I'm trying to set up something similar to IIS's IsClientConnected > property so that I can check if a user received all output or if their > connection was aborted/dropped before that (e.g., make sure they > received an entire one-time download).
There is technically no way that you can determine what you want in that way. Something like the IsClientConnected property of IIS can't tell you that either. If it is being claimed that it can, then the claim is wrong. The best you can get is an indication that all data had been written onto the socket connection back to the client prior to the connection being terminated. This will not though tell you if the client actually received all of the data. It is entirely possible that the connection got dropped by an intermediary before the client had a chance to read the data, even though from the server perspective it had been written. This is case because network connections have a level of buffering. A successful write onto a socket connection is merely telling you that the data has been buffered for sending, not that the other end has finished reading it. > I've read through these posts/references: > > "client connection closed" issue > http://groups.google.com/group/modwsgi/browse_thread/thread/71557453903756a8 > > cancelling a request if client closes http socket > http://groups.google.com/group/modwsgi/browse_thread/thread/8ebd9aca9d317ac9 > > [Web-SIG] Closing long-running WSGI requests (possible?) > http://www.mail-archive.com/[email protected]/msg02661.html > > Registering Cleanup Code > http://code.google.com/p/modwsgi/wiki/RegisteringCleanupCode > > It *seems* like I should be able to do this by using yield to return a > generator. The code seems to sync up with that: > http://code.google.com/p/modwsgi/source/browse/tags/mod_wsgi-2.3/mod_wsgi.c#3047 > > However, if I simulate this, the generator gets exhausted and its > close operation called before mod_wsgi logs its "IOError: client > connection closed" error. I added debugging output to > encode_unicode_app_iter in paste.wsgilib, which appears to be the very > last step before mod_wsgi part just to make sure I still have a > generator at that point. > > Am I missing something to get this working? Send a small code snippet that demonstrates what you are doing then maybe can comment. It may be that buffering is the issue as explained above. Probably the only way to get confirmation is for the client to send a subsequent request to say that is has read all the data it could and how much it did actually read, the latter being validated against how much was sent. This could probably be packaged up nicely in some AJAX way with JS to be transparent to a user of the web page. Difficulties might come with where have multi process server. Just means though that state about the request would need to be stored in way accessible by all server process. Graham --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "modwsgi" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en -~----------~----~----~----~------~----~------~--~---
