Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get 502 Bad Gateway when AJAX Request #5

Closed
joeyew opened this issue Jun 19, 2015 · 5 comments
Closed

Get 502 Bad Gateway when AJAX Request #5

joeyew opened this issue Jun 19, 2015 · 5 comments

Comments

@joeyew
Copy link

joeyew commented Jun 19, 2015

Phalcon version: 1.3.6
Php version : 5.5.19

echo json_encode($users->toArray());

When we return the json format as response to Ajax, it will occur error 502: Bad Gateway.
If we disable the phalcon-debugbar, everything is fine.

I also tested it in phalcon version 2.0.2, but it was fine.

@snowair
Copy link
Owner

snowair commented Jun 19, 2015

I'v fixed it, you can test again.

@joeyew
Copy link
Author

joeyew commented Jun 22, 2015

Hi, Thank you but unfortunately, it's still not working.
I've found the error occur when it's call the collect function at PhalconDebugbar.php line 698.

When the time collector is loaded, it will throw the error.

@snowair
Copy link
Owner

snowair commented Jun 22, 2015

Hi,I don't know where to get phalcon 1.3.6, so I test ajax request on Phalcon 1.3.5/PHP5.4/Ubuntu14.04/Nginx 1.8 using the INVO project.

This is my test code:

class IndexController extends ControllerBase
{
    public function initialize()
    {
        $this->tag->setTitle('Welcome');
        parent::initialize();
    }

    public function indexAction()
    {
        \PhalconDebug::addMeasurePoint('index');
    }

    public function testAction()
    {
        $this->view->disable();
        echo json_encode(['key1'=>1,'key2'=>2]);
    }
}

views/index.volt:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        {{ get_title() }}
        {{ stylesheet_link('css/bootstrap.min.css') }}
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="Your invoices">
        <meta name="author" content="Phalcon Team">
    </head>
    <body>
        {{ content() }}
        {{ javascript_include('js/jquery.min.js') }}
        {{ javascript_include('js/bootstrap.min.js') }}
        {{ javascript_include('js/utils.js') }}
        <script type="text/javascript">
                jQuery.post('/index/test',{},function(data){
                    console.log(data);
                });
        </script>
    </body>
</html>

It works ok.

Could you tell me any more infomation about your problem. Linux or Wn? Simple App , Mulit module or Micro App?

I suggest you test on phalcon 1.3..4/1.3.5, because they are offical version.

Also, You can go on debuging into TimeDateCollector::collect method . It's a very simple method, so you can comment line by line to find out the 'culprit' line.

Thank you for your test, I hope we can fix it togethor.

@joeyew
Copy link
Author

joeyew commented Jun 22, 2015

I am using version 1.3.4, not 1.3.6, sorry for wrong information provided.
my production environment is Centos 6.5 with Nginx 1.6.3.

My Application is separate into 2 modules, which is frontend and backend.

We found the collector have problem only when it counted to 10, so we disabled it temporary as workaround.

foreach ($this->collectors as $name => $collector) {
            if($count!=10) {
                $this->data[$name] = $collector->collect();
            }
            $count++;
}

@snowair
Copy link
Owner

snowair commented Jun 28, 2015

I had test again, but it work.

Maybe you could copy a config file to your project directory instead the default config file, like this:

 (new \Snowair\Debugbar\ServiceProvider('../apps/debugbar.php'))->start();

you could disable any unnecessary collectors or disable capture ajax request by edit your config file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants