javascript - Failed to load resource: the server responded with a status of 504 (Gateway Timeout) -
i developing project using django - python, javascript. when call long running process (time-consuming) approx more 20 minutes views process starts successfully. used loader in ajax notify user process running. after process completes loader stop , change completed state.
but issue every time after 14.59 minutes process started, loader stops , status change completed. process running in background not yet completed. page crash after time. after process complete bind result under tag in web page. in tag error 504 (gateway timeout) arise. in web console log failed load resource: server responded status of 504 (gateway timeout), above error prints. if knows please me fix this.
is django closing connection after time ? if there possible mention timeout in django settings (settings.py). tried giving timeout in ajax call same issue returns. doubt on django development server. there timeout in django development server. when search issue found, in nginx server same type of issue arise. django depend on nginx or using ?
i tried provide information regarding issue if further clarifications, please let me know.
the server closes connection after particular amount of time, can modified changing configuration, not approach. suggest try reduce time taken script by:
- optimizing code.
- by caching data used often
- using backend services process data , store them in temporary storage such memcache or redis can accessed.
also should handle timeout of ajax call:
$.ajax({ ... timeout: 1000, error: function(jqxhr, textstatus, errorthrown) { if(textstatus==="timeout") { //do on timeout / show appropriate message. } } });
references tweaking performance , optimizing coding techniques reducing time: https://docs.djangoproject.com/en/1.10/topics/db/optimization/ https://docs.djangoproject.com/en/1.10/topics/performance/ https://realpython.com/blog/python/caching-in-django-with-redis/
Comments
Post a Comment