Forum: Rails deployment Mongrel, Nginx, and AJAX not working

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Jason R. (Guest)
on 2007-07-24 21:11
(Received via mailing list)
Under Apache / FastCGI, the following request is perfectly fine (as
from the browser's View Source):

{asynchronous:true, evalScripts:true, method:'get'})

However, under my new setup of Nginx and Mongrels, the call never
returns. I
get the proper log in production.log, stuff happens, and my browser just
sits there twiddling it's thumbs, never getting what it wants back
the update *is* meant to be part of the GET string).

Has anyone else had a problem with this kind of setup? It feels that
responses are getting stopped by Nginx but I can't find anything out


Vince W. (Guest)
on 2007-07-24 21:22
(Received via mailing list)
I know this isn't the answer you're looking for, but I ran into issues
like this at least 3 times with lighttpd which is why I switched to
nginx/mongrel.  Each time I had a problem, firebug was essential in
figuring out the problem.. maybe take a look at the output from
firebug and see if it helps..


On 7/24/07, Jason R. <removed_email_address@domain.invalid> wrote:
> the update *is* meant to be part of the GET string).
support independent business --
Jason R. (Guest)
on 2007-07-24 21:30
(Received via mailing list)
Yeah, I've been watching Firebug, the request just spins until it times
Getting back into the server works no problem, but there's nothing
back to my browser.

Thanks though. Interesting that you had this same problem with lighty.

Zed A. Shaw (Guest)
on 2007-07-25 00:57
(Received via mailing list)
On Tue, 24 Jul 2007 13:10:42 -0400
"Jason R." <removed_email_address@domain.invalid> wrote:

> Under Apache / FastCGI, the following request is perfectly fine (as pulled
> from the browser's View Source):
> new Ajax.Request('http://server/portals?editable=true&amp;update=por...,
> {asynchronous:true, evalScripts:true, method:'get'})

What happens when you do & rather than &amp; ?

Zed A. Shaw
- Hate:
- Good:
- Evil:
Pascal Belloncle (Guest)
on 2007-07-25 08:57
(Received via mailing list)
I had a very similar thing happen a few days ago and found a solution
for my problem last night.  That was Ajax request and firebug was
showing the request as spinning and spinning...

The code was using Ajax.Request with a post (not a get), and worked
fine just with mongrel, but through nginx, it was taking 120s to get
back to that Complete state (and, although I'm not sure why, the
reason it was taking 120s was probably that another Ajax request was
being fired up every 120s).

The code responding to the request couldn't be simpler:

     render :text => @mailbox.count.unseen

unseen happens to return an integer, not a string.  And when trying
with a string it worked

     render :text => "1234567890"

So just for a moment I thought it was the size of the request, but
even a 1 byte string did not make any difference and still worked. So
just changing that line to:

     render :text => @mailbox.count.unseen.to_s

fixed it for me.  I have not attempted to figure out further what was
happening, but my best theory is that the mime type returned by rails
(mongrel?) may be different and nginx (or the browser?) is waiting
for more to send the response back).

Not sure the same thing is happening in your case, but that may be
worth looking more closely at the mime type.

Jason R. (Guest)
on 2007-07-27 19:02
(Received via mailing list)

I honestly do not know what I did, but it's working now. I did install
swiftiply to use it's evented_mongrel handler, so there might be
there that fixed the problem but I'm not sure.

Thanks for all of your suggestions.

Jason R. (Guest)
on 2007-07-27 21:34
(Received via mailing list)
Follow-up # 2

Ignore previous post, I'm still stuck, though I know what's wrong now.
is a site migration so traffic already exists to the url. I put up the
on the new box under a different url to see if it works and sure enough,
was snappy and perfect. Thinking all was good, I changed the DNS entry
the real URL and bam, back to a broken site.

So this is a load balancing issue then, or at least that's what it looks
like. I now know the whole stack works, but under a site that gets
but in no ways heavy load, requests responses get lost. Literally.

As for the mime type, I'll definitely look into that but all of my
are RJS and thus strings.


Jason R. (Guest)
on 2007-07-28 00:30
(Received via mailing list)
So I just decided to bypass the problem and move to a different URL. Not
going to deal with it if I can just get around it.

This topic is locked and can not be replied to.