How to debug a "pending" HTTP request to a PHP web app? - php

I'm maintaining an old CodeIgniter web app.
Lately, when certain forms are saved, the browser shows a permanent "Pending" for the status of the request. The request never completes (unless I reboot the web server in which case it errors out immediately).
There aren't any client-side errors in Dev Tools.
There aren't any server-side errors in the logs.
This happens in different browsers.
It happens in a Chrome incognito window with no extensions loaded.
All I have to go on is, the submit button it hit, the browser says "waiting for <servername>" and nothing else happens.
Does this look like a network problem? There was no problem loading any of the application's other pages, all of which came out of the same database and web server.
How do I debug a "pending" HTTP request in a browser, when neither the client or the server shows an error?
TIA

You can rule out a network problem because the other sites are working. If the same site sometimes works and sometimes won't there could be a network problem but this isn't very likely.
The fact that the request is pending and there aren't any errors means that the server accepted the request and is handling it. When there is no error the server handles it until either an error appears or the response is returned by the php processor.
This brings me to the assumption that the problem is an endless loop or a long running function in your serverside code.
error detection procedure
First check that the error reporting is enabled in index.php.
Now you could wait wait till the code runs in a timeout and throws an error
and/or
you could go to the config/routes.php and check which controller and function handles the request and break down the functions and test which one takes this long.
If you need further help please paste some code.

Related

How to debug "Waiting For mydomain.com" web-request getting stuck at pending state

I'm currently in the process of moving my webserver from an on-premise solution AWS EC2. I've installed an ec2 web-server with VestaCp admin panel that configures Apache & Nginx.
Everything seems to work, except a request sometimes seems to get 'stuck'. Meaning I click on a link, and instead of navigating to that link it's added to my chrome network tab in pending state, here in the picture below you can see the pending web request that was triggered by a click on an a href, and instead of navigating to it it's stuck at pending state for more than a minute!
While this is happening, the browser is showing a "waiting for mydomain.com" in the bottom left corner.
I've tried moving the session to be saved in memcached (instead of file), and enabled opcache, but really haven't been able to debug this properly and nail down on the problem (I just had an hunch it might have something to do with a locked file and someone waiting on the lock). I haven't been able to find something relevant in the apahce error logs. I've also tried chrome net-internals sockets view, but it doesn't seem it's being stalled. During debug I've managed to track the a href click and the Apache access log, and noticed the request doesn't reach the Apache Access log, meaning it probably gets stuck in the client (unless the access log only updates when the request finishes)
What can cause this? What are ways to debug deeper?
Had exactly the same problem, nginx gets stuck sometimes for exactly 60 seconds.
In the end the problem was solved after I added "resolver" directive to nginx. Not entirely sure about the actual mechanism that caused this problem.

Multiple AJAX calls work locally but fail on the server (500 error resource not found)

This is something weird. I am developing an app that checks via AJAX if the session timed out at every page load and every user action. On top of this, I make other ajax calls for other user actions.
This works well on my xampp server, locally. However, when I'm testing them on my client's server, a shared host working on a CPanel thingy, the first AJAX call works, and then all the other calls fail with an error code of 500.
Is this familiar to someone?
PHP has a session lock, Check that your session is not locked after the first session starts. I had once face these problem in my own PHP MVC framework where i was actually requesting multiple times the url with the jquery, after first one then my session was locked, check on it, if that might be the case

WordPress Installation showing error message in iPage Hosting

Hello i am new baby in wordpress CMS.
I bought iPage Hosting for my website.
When i installed wordpress to my hosting , this error message is showing.
Server Response Empty
Your server responded with a blank page, which means your server is having difficulties processing PHP requests. If you are not familiar with this error (potentially a "500" Error), please contact your server admin or web host about possible resolutions.
How can i solve it?
"500" error indicate that it's Internal Server Error.
Cause of HTTP 500 Errors
The 500 Internal Server Error is a very general HTTP status code that means something has gone wrong on the web site's server but the server could not be more specific on what the exact problem is.
Most of the time, "gone wrong" means an issue with the page or site's programming, nothing you have anything to do with.
How To Fix the 500 Internal Server Error
The 500 Internal Server Error is a server-side error, meaning the problem probably isn't with your computer or Internet connection but instead is a problem with the web site's server.
While not probable, it is possible that there's something wrong on your end and we'll look at some things you can try.
Reload the web page. You can do that by clicking the refresh/reload button, pressing F5, or trying the URL again from the address bar.
Even if the 500 Internal Server Error is a problem on the web server, the issue may only be temporary. Trying the page again will often be successful.
Clear your browser's cache. If there's a problem with the cached version of the page you're viewing, it could be causing HTTP 500 issues.
Note: Internal Server Errors are not often caused by caching issues but I have, on occasion, seen the error go away after clearing the cache. It's such an easy and harmless thing to try so don't skip it.
Delete your browser's cookies. Some 500 Internal Server Error issues can be corrected by deleting the cookies associated with the site you're getting the error on.
After removing the cookie(s), restart the browser and try again.
It's not very common, but some servers produce a 500 Internal Server Error when in reality the more appropriate message based on the cause of the problem is 504 Gateway Timeout.
Contact the website directly. Chances are good that the website administrators already know about the 500 error but if you suspect they don't, letting them know helps both you and them (and everyone else).
The best way to find contact information for a website is through a WHOIS search, using the domain name as your search term.
Normally, you need to go into your files and delete the .htaccess. A new one will automatically replace it and it will fix the issue. If you can't find the .htaccess or whichever server file your host is using, contact them to remove it. I hope that helps!
Sure, this is a temporary fix in the Visual Composer plugin itself. However the next update will address it from the Theme side and will not have to rely on Visual Composer adding a check for it.
Locate the following file on your server: /wp-content/plugins/js_composer/include/classes/core/class-wpb-map.php
Unzip and replace it with this file:
http://help.themeva.com/tmp/class-wpb-map.php.zip

Issues with PHP cURL between servers, return transfer probably wont catch the response

I have a really weird behavior going on.
I'm hosting a tracking software for users, that mainly logs mobile traffic. Now, the path is as follows:
1. My client gets a php code snippet to put in his website.
2. This code sends a cURL post (based on predefined post fields like: visiotr IP, useragent, host etc) to my server.
3. my server logs the data, and decide what the risk level is.
4. it then responds the client server about the status. That is, it sends "true" or "false" back to the client server.
5. client server gets that r
esponse, and decides what to do (load diffrent HTML content, redirect, block the visitor etc).
The problem I'm facing is, for some reason, all the requests made from my client's server to my server, are recorded and stored in the a log file, but my clients report of click loss as if my server sends back the response, but their server fails to receive those responses or something.
I may note that, there are tons of requests every minute from different clients' servers, and from each client himself.
Could the reason be related to the CURL_RETURNTRANSFER not getting any response ? or, maybe the problem is cURL overload ?
I really have no idea. My server is pretty fast, and uses only 10% of its sources.
Thanks in advance for your thoughts.
You touched very problematic domain - high load servers, you problem can be in so many places, so you will have to really spend time to fix it, or at least partially fix.
First of all, you should understand what is really going on, check out this simplified scheme:
Client's php code tries to open connection to your server, to do this it sends some data via network to your server
Your server (I suppose apache) tries to accept it, if it has resources - check max connections properties in apache config
If server can accept connection it tries to create new thread (or use one from thread pool)
After thread is started, it runs your php script
Your php script do some work, connecto to db and sends response back via network
Client waits till the answer from p5 or closes connection because of timeout
So, at each point you can have bottleneck:
Network bandwidth
Max opened connections
Thread pool size
Script execution time
Max database connections, table locks, io wait times
Clients timeouts
And it is not a full list of possible places where problem can occur and finally lead to empty curl response.
From the very start I suggest you to add logging to both PHP codes (clients and servers) and store all curl_error problems in some text file, at least you will see what problems occur often.

updating database with ajax- handling with errors

Im building a website where the user uses ajax calls in order to update the database. Its works well on xammp but im worried that problems may happen frequently when the site will be on the net.
i've got some questions:
If ajax fails (and my code is good), is it always because of connections?
Can an attempt fail but succeed later?
What is the best way to handle those failed requests?
If ajax fails (and my code is good), is it always because of connections?
An Ajax call can fail for a variety of reasons. Reasons can be, but are not limited to: Javascript error, Network Timeout, Serverside error, JS Performance, Browser settings, etc
Can an attempt fail but succeed later?
If your AJAX request fails it will not automaticly retry. You need to program that yourself.
What is the best way to handle those failed requests?
You should have error handling in javascript to check for the errors. Basicly there are 3 cases:
Correct response from server
Response from server, but with incorrect return (failed serverside)
No Response from server (failed clientside)
You can either notify the user of a failed request or retry a few times and notify the user later, if the request never completes.

Categories