Welcome Guest, Not a member yet? Register   Sign In
Using set_flashdata too many times results in 502 Bad Gateway error
#1

[eluser]jay-2003[/eluser]
Hi,

I have written a form builder system as part of a CMS, the system allows an administrator to generate input fields and add validation etc

The results of the validation are stored in "set_flashdata" variables to display the form errors and re-populate the form.

If I have up to around 10 fields the form works fine, but any more than that and I get:

502 Bad Gateway
The server returned an invalid or incomplete response.

I have narrowed down the problem to having too many set_flashdata variables (each field creates 2 flashdatas to store the error and the post variable to re-populate the form and one form the customer has created has 65 fields). The validation works fine when I comment out the loop that creates the flashdata so it is definately this that is causing the problem.

Is there anything I can do to work around this? I am thinking about doing a batch insert of the errors and form data to a table, then passing a unique ID for this instance of form submission back via flashdata to load the results from the DB. Seems a little overkill though, anyone got any ideas?

Thanks in advance

Jason
#2

[eluser]noideawhattotypehere[/eluser]
Are you using nginx?
#3

[eluser]jay-2003[/eluser]
Hi,

Nope servers arent running nginx.

Server is running MySQL v5.5.33 & PHP 5.3.27

Thanks

Jason



#4

[eluser]CroNiX[/eluser]
Are you by chance using cookies for your session storage? If using a cookie (default), you can only store a max of 4K of data (limitation of cookie, not CI), after encryption, etc, has taken place. After the cookie fills, it breaks because the session class then can't unserialize the stored array since the text is now malformed with the end chopped off.

So I'd use database sessions where you have basically unlimited storage for session data if this is the case, or just use a regular array that you store the submitted data in that your controller receives and pass it back to your view like normal.
#5

[eluser]jay-2003[/eluser]
CI is set to use DB sessions, but i'm wondering if its listening to the config file as if I disable encryption I can add an extra field before it throws the 502 error.

I will look into it and see if I can track down the issue.

Thanks

Jason
#6

[eluser]noideawhattotypehere[/eluser]
[quote author="jay-2003" date="1383583140"]Hi,

Nope servers arent running nginx.

Server is running MySQL v5.5.33 & PHP 5.3.27

Thanks

Jason



[/quote]

you sure its not nginx? it can run mysql and php aswell lol. these things doesnt happen on apache as there is no cookie limit, while nginx has one.
#7

[eluser]vanquish[/eluser]
Hi Jay, I'm not sure if you resolved this issue but I had the same problem and was able to solve it thanks to this tip someone posted on StackOverflow. Hopefully it helps anyone else who has the same issue!

Quote:I figured out what was wrong. First of all, a colleague with more server knowledge explained me that my setup probably was such that nginx received all the requests, and then directly served static files. for non-static request, it passed on the work to apache, and serves as an intermediary. So probably something went wrong when apache tried to send data to nginx (or when nginx tried to send information to apache).

As I never worked with nginx before, I also did not think of checking the nginx log files. And there was an error that I could use:

[error] 27453#0: *9223 upstream sent too big header while reading response header from upstream, client:

I ended up applying the first bit of this other stack overflow solution:

Add this to your nginx.conf file normally located at
Code:
/etc/nginx/nginx.conf:

proxy_buffer_size   128k;
proxy_buffers   4 256k;
proxy_busy_buffers_size   256k;
By the way, it should be added to the http section of the file. That was something what was missing from the solution.




Theme © iAndrew 2016 - Forum software by © MyBB