Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Thu May 23, 2013 1:44 pm 
Offline
Junior Member

Joined: Thu Dec 27, 2012 8:33 pm
Posts: 28
I'm creating a django app in which I pass data via json from my server to the broswer to load new content as a user scrolls. Everything works fine on django's dev server on my laptop, but on the production server (still only used by a few tester users), certain items will consistently cause 500 errors. I believe it is because they are too large, but I don't know what setting to adjust to accomodate it.

The error from nginx access log (not very helpful):

Code:
[redacted IP] - - [23/May/2013:16:40:40 +0000] "POST /nextitems/VLPCQVAMGV/21/21/ HTTP/1.1" 500 2006 "http://[redacted domain].com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31"


For one of the items that works fine on my laptop, but fails on the server, the log from the django runserver is:

Code:
[23/May/2013 04:01:12] "POST /nextitems/U48ST0SB84/36/36/ HTTP/1.1" 200 25216


That size (25216 bytes) is relatively large for the json I'm trying to pass, which is why I think it fails on the server. I also have another method to pass the same item as html, which works on the server (indicating it's not a database problem, and seems to be specific to passing json).

I also looked at the uwsgi log and I see (for a different nextitems call that caused a 500):

Code:
[pid: 3390|app: 0|req: 461/918] [redacted IP] () {50 vars in 916 bytes} [Thu May 23 12:35:58 2013] POST /nextitems/VX5VEQEA6G/21/21/ => generated 1994 bytes in 37 msecs (HTTP/1.1 500) 3 headers in 121 bytes (1 switches on core 0)


which looks OK, but chrome shows me:

Code:
POST http://[redacted IP].com/nextitems/VX5VEQEA6G/21/21/ 500 (INTERNAL SERVER ERROR) 



Any ideas on how to fix this or how to further debug it? Thanks in advance!


Top
   
PostPosted: Thu May 23, 2013 3:39 pm 
Offline
Senior Newbie

Joined: Sat Oct 01, 2011 10:06 am
Posts: 5
Location: Massachusetts, USA
I think you may wanna tweak client_max_body_size in nginx.conf. It's default to 1024 bytes, your 25216 bytes is way larger than that.

Here is the ref
http://wiki.nginx.org/HttpCoreModule#cl ... _body_size


Top
   
PostPosted: Thu May 23, 2013 4:04 pm 
Offline
Junior Member

Joined: Thu Dec 27, 2012 8:33 pm
Posts: 28
Thanks for the reply. My understanding is that client_max_body_size is for size of the request TO the server (please correct me if I'm mistaken), but my issue is occuring when passing a json response FROM the server to the browser. The request to the server in this case is quite small.

Are you aware of a setting in nginx or elsewhere that would help send large json responses from the server?


Top
   
PostPosted: Thu May 23, 2013 7:56 pm 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
If you set DEBUG=True in your settings.py, you should be getting a lot of not-JSON that will explain what happened; you can trap this in your browser's development tools.

You might also want to consider Sentry... it's either available as a standalone server, or as a paid service, and it is indispensable for app development.

_________________
Code:
/* TODO: need to add signature to posts */


Top
   
PostPosted: Thu May 23, 2013 8:17 pm 
Offline
Junior Member

Joined: Thu Dec 27, 2012 8:33 pm
Posts: 28
hoopycat, I can't believe I didn't think to set debug to True on production (I've solved problems on the server that way before)... I figured out the error, which was the result of a standard output unicode problem. It's crazy the patterns you think you see when problems creep up. I'm still not sure why it didn't cause problems on the dev server, but the problem is resolved.

Thanks!


Top
   
PostPosted: Thu May 23, 2013 8:25 pm 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
Oh, and it's *always* a Unicode encoding problem. :-)

_________________
Code:
/* TODO: need to add signature to posts */


Top
   
PostPosted: Fri May 24, 2013 1:33 am 
Offline
Senior Member

Joined: Fri Jul 03, 2009 2:31 am
Posts: 54
ICQ: 897607
Just a note for future use: instead of setting DEBUG=True on a production server this snippet should be a little more secure and let you do the same thing as a superuser: http://ericholscher.com/blog/2009/sep/5 ... revisited/


Top
   
PostPosted: Fri May 24, 2013 1:59 pm 
Offline
Junior Member

Joined: Thu Dec 27, 2012 8:33 pm
Posts: 28
That is good advice, thanks. I'll try that out.


Top
   
PostPosted: Fri May 24, 2013 10:49 pm 
Offline
Junior Member

Joined: Thu Dec 27, 2012 8:33 pm
Posts: 28
I also just realized that my server had been emailing me the 500 debug info the entire time, but gmail was was filtering it as spam.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group