programing

Safari ajax request Failed to load resource: The network connection was lost

css3 2023. 9. 7. 21:58

Safari ajax request Failed to load resource: The network connection was lost

I'm receiving a message "Failed to load resource: The network connection was lost." in my application, which uses ajax requests to get content from server. This error is only in Safari, other browsers are ok.

I was searching last few hours and found that it can be due to http headers:

전송-부호화 : 청크됨
연결: keep-alive
내용-길이

I've found something similar: https://github.com/woothemes/woocommerce/issues/7176 On the bottom is told that they set

브라우저 일치 "Safari" neo keepalive
.htaccess에서

Is there any similar solution or settings for nginx server?

Thank you

JF

One of the reasons why it might happen is the way Safari handles some SSL certificates (mainly, LetsEncrypt). The solution is to put the line:

ssl_session_cache shared:SSL:10m;

to your nginx config.

Source: https://community.letsencrypt.org/t/apple-safari-browsers-fail-to-connect/3731/3

Had this trouble too with a form that ajax-posted and when that completed did a window.location.reload(true). Safari 13.0.3 would work the first time after a manual page refresh (seemed consistent) then would get "Failed to load resource: The network connection was lost." roughly 2 out of 3 clicks.

Changed the client to:

  • use ajax-get instead of post (with a unique query param value each time)

  • on completion set a timer so that window.location.reload(true) was not done inside the ajax completion handler

User reports that worked, not sure which one of those changes or both.

Hope this helps someone...

ReferenceURL : https://stackoverflow.com/questions/33895463/safari-ajax-request-failed-to-load-resource-the-network-connection-was-lost