javascript - Disconnect a jquery connection after an inactivity period -
i'm using tcp keepalive on server side keep connection alive, , notify server if client dies. how can configure jquery.get() disconnect connection after period of idle time?
edit - consider "idle time" time no tcp packets exchanged. since server has tcp keepalive, send 0-data packets client.
@j-p's answer not exact match want. if connection open, has keep-alive traffic no data, keep open indefinitely.
use timeout
option:
jquery.ajax({ url: '...', timeout: 3000, success: function(){ /*...*/ } });
or, if want same timeout requests:
$.ajaxsetup({ timeout: 3000 });
Comments
Post a Comment