Long Polling with Nginx - advice and clarification -
i'd clarification on long-polling requests. made script long polling, tried on nginx (with standard configuration) , works. noticed things. after 60 seconds if server not respond nginx returns 503 error in log browser, possible (or should) not never expire request, when server responds? if possible, how can do? if not possible, advise me stretch out request until server stops (60 seconds) or before (indicate how time)? if before, how advise me terminate application?
client_body_timeout , client_header_timeout you're looking for
client_body_timeout 1m; # or 60s client_header_timeout 1m;
change values how long want, more commonly used method example 60 seconds server sends empty response (terminate connection), client restarts new request, last 60 seconds, etc.., cause believe otherwise if user doesn't end request closes browser example, have lot of useless open connections waiting timeout.
edit: don't make request expire nginx, let application send response, otherwise you'll 504 error not 200 success. if want make long poll 60 seconds set nginx 90 or 120 seconds example, when application exceeds 60 seconds should send empty output, or maybe message says there's no message yet 'end' or 'stop', javascript should initiate new request after receiving stop message. bit of javascript make server send multiple messages without terminating connection using separator or something,
tell 1 method fits works isn't good, browsers chrome , firefox can use fancier methods server sent events or web sockets, there's lot of parser libraries check functions supported current browser , uses best one, if you're going use server sent events example aren't supported in ie yet, handle this example, , fall long polling in ie.
Comments
Post a Comment