# Safari intermittently hangs when loading FCGI request

**URL:** <https://www.ruby-forum.com/t/safari-intermittently-hangs-when-loading-fcgi-request/197688>\
**Category:** NGINX\
**Created:** [October 18, 2010, 11:08pm UTC](https://www.ruby-forum.com/t/safari-intermittently-hangs-when-loading-fcgi-request/197688 "2010-10-18T23:08:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![okkezSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Post date:** [October 18, 2010, 11:08pm UTC](https://www.ruby-forum.com/t/safari-intermittently-hangs-when-loading-fcgi-request/197688/1 "2010-10-18T23:08:13Z")

</div>

As you can see in attached debug log there is ±20 second delay before  
returning the page to Safari 5.0.2. Profiling PHP-FPM and PHP script  
itself show that they render under 0.03 seconds. The connection stall is  
not happening in Firefox 3.6.10

These are the response headers in Safari:  
Connection:close  
Content-Type:text/html  
Date:Mon, 18 Oct 2010 20:56:23 GMT  
Server:nginx/0.8.52  
Transfer-Encoding:Identity

These are the response headers in Firefox:  
Server: nginx/0.8.52  
Date: Mon, 18 Oct 2010 20:56:02 GMT  
Content-Type: text/html  
Transfer-Encoding: chunked  
Connection: close

I tested Nginx 0.8.52 with gzip off, keepalive\_timeout 0,  
fastcgi\_max\_temp\_file\_size 0 but no difference.

nginx version: nginx/0.8.52  
TLS SNI support enabled  
configure arguments: --conf-path=/etc/nginx/nginx.conf  
–error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid  
–lock-path=/var/lock/nginx.lock  
–http-log-path=/var/log/nginx/access.log  
–http-client-body-temp-path=/var/lib/nginx/body  
–http-proxy-temp-path=/var/lib/nginx/proxy  
–http-fastcgi-temp-path=/var/lib/nginx/fastcgi  
–http-uwsgi-temp-path=/var/lib/nginx/uwsgi  
–http-scgi-temp-path=/var/lib/nginx/scgi --with-debug  
–with-http\_stub\_status\_module --with-http\_flv\_module  
–with-http\_ssl\_module --with-http\_gzip\_static\_module  
–with-http\_realip\_module --with-ipv6 --without-mail\_pop3\_module  
–without-mail\_imap\_module --without-mail\_smtp\_module --with-file-aio  
–add-module=/build/buildd/nginx-0.8.52/contrib/nginx-upload-progress-module

---

<div class="post-metadata">

**Author:** ![senh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e47c2d/32.png) [@senh](https://www.ruby-forum.com/u/senh)\
**Post date:** [October 19, 2010, 10:17am UTC](https://www.ruby-forum.com/t/safari-intermittently-hangs-when-loading-fcgi-request/197688/2 "2010-10-19T10:17:46Z")

</div>

Hello!

On Mon, Oct 18, 2010 at 11:08:13PM +0200, Sen Haerens wrote:

> Transfer-Encoding:Identity
> 
> –http-scgi-temp-path=/var/lib/nginx/scgi --with-debug  
> –with-http\_stub\_status\_module --with-http\_flv\_module  
> –with-http\_ssl\_module --with-http\_gzip\_static\_module  
> –with-http\_realip\_module --with-ipv6 --without-mail\_pop3\_module  
> –without-mail\_imap\_module --without-mail\_smtp\_module --with-file-aio  
> –add-module=/build/buildd/nginx-0.8.52/contrib/nginx-upload-progress-module
> 
> Attachments:  
> [http://www.ruby-forum.com/attachment/5218/safari.connection.normal.log](http://www.ruby-forum.com/attachment/5218/safari.connection.normal.log)  
> [http://www.ruby-forum.com/attachment/5219/safari.connection.slow.log](http://www.ruby-forum.com/attachment/5219/safari.connection.slow.log)  
> [http://www.ruby-forum.com/attachment/5220/safari.connection.slow2.log](http://www.ruby-forum.com/attachment/5220/safari.connection.slow2.log)

These logs doesn’t contain full logs for any single request. On  
the other hand, each file contains parts of _two_ different  
connection logs. E.g. in slow2.log:

2010/10/18 23:02:48 [debug] 26728#0: \*146 http finalize request: 0,  
“/index.php?/jobs/” a:1, c:1  
2010/10/18 23:03:19 [debug] 26728#0: \*151 http finalize request: 0,  
“/index.php?/estimates/” a:1, c:1

These are two distinct connections, \*146 and \*151. Each  
connection itself doesn’t seem to be problematic.

Maxim D.

---

<div class="post-metadata">

**Author:** ![senh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e47c2d/32.png) [@senh](https://www.ruby-forum.com/u/senh)\
**Post date:** [October 19, 2010, 3:40pm UTC](https://www.ruby-forum.com/t/safari-intermittently-hangs-when-loading-fcgi-request/197688/3 "2010-10-19T15:40:49Z")

</div>

It did some further testing and Safari with User-Agent Firefox is  
working correctly. Only difference I could notice is that in this case  
Keep-Alive connections are enabled.

As a final solution I removed the else condition in  
/src/http/ngx\_http\_core\_module.c (line 806) that disables keep-alive  
connections for Safari by default. What’s the reason this is hardcoded  
by default in Nginx source?

Maybe add an option to make this user configurable in the future? Even  
[apple.com](http://apple.com) is sending Keep-Alive headers. I suppose they know what they  
are doing. 😉

---

<div class="post-metadata">

**Author:** ![senh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e47c2d/32.png) [@senh](https://www.ruby-forum.com/u/senh)\
**Post date:** [October 19, 2010, 3:50pm UTC](https://www.ruby-forum.com/t/safari-intermittently-hangs-when-loading-fcgi-request/197688/4 "2010-10-19T15:50:25Z")

</div>

On Tue, Oct 19, 2010 at 03:40:49PM +0200, Sen Haerens wrote:

> It did some further testing and Safari with User-Agent Firefox is  
> working correctly. Only difference I could notice is that in this case  
> Keep-Alive connections are enabled.
> 
> As a final solution I removed the else condition in  
> /src/http/ngx\_http\_core\_module.c (line 806) that disables keep-alive  
> connections for Safari by default. What’s the reason this is hardcoded  
> by default in Nginx source?

> **[5760 – Safari hangs when uploading files to certain php scripts](https://bugs.webkit.org/show_bug.cgi?id=5760)**

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![senh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e47c2d/32.png) [@senh](https://www.ruby-forum.com/u/senh)\
**Post date:** [October 19, 2010, 4:00pm UTC](https://www.ruby-forum.com/t/safari-intermittently-hangs-when-loading-fcgi-request/197688/5 "2010-10-19T16:00:59Z")

</div>

Igor S. wrote in post #955427:

> [5760 – Safari hangs when uploading files to certain php scripts](https://bugs.webkit.org/show_bug.cgi?id=5760)

I understand but why is Keep-Alive not only disabled for POST requests  
then?

---

<div class="post-metadata">

**Author:** ![senh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e47c2d/32.png) [@senh](https://www.ruby-forum.com/u/senh)\
**Post date:** [October 19, 2010, 4:06pm UTC](https://www.ruby-forum.com/t/safari-intermittently-hangs-when-loading-fcgi-request/197688/6 "2010-10-19T16:06:49Z")

</div>

On Tue, Oct 19, 2010 at 04:00:59PM +0200, Sen Haerens wrote:

> Igor S. wrote in post #955427:
> 
> > [5760 – Safari hangs when uploading files to certain php scripts](https://bugs.webkit.org/show_bug.cgi?id=5760)
> 
> I understand but why is Keep-Alive not only disabled for POST requests  
> then?

POST may go on keep-alive connection after GET.

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**
