Apache2 with PHP - Pages Not Loading Without Bypassing Cache - php

I have a weird issue where my PHP pages being served by Apache2 will not load on the page without having to bypass the browser cache (Ctrl+Shift+R).
If I got to mypage.com/test.php I get a browser erro page: The connection was reset (Firefox)
or Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data. (Chrome)
If I do a Ctrl+Shift+R on the page then the test.php which is just a call to phpinfo(), then the page loads normally and I see the PHP output.
I'm running on Ubuntu with a virtual host for the specific site using PHP 5.3.2. If I do a curl on the mypage.com/test.php on the server it loads the page fine. But not on PC browsers on or off the network.
Does anyone know why this is happening or how to get Apache to serve the page without the CTRL+Shift+R?

Try use something like https://addons.mozilla.org/ru/firefox/addon/live-http-headers/ to get full text of requests and answers in browser.

Related

TYPO3 and IOS: can't open the page

My situation:
I have 10 typo3-websites running on two servers:
First Server (apache with php 5.6.32):
typo3 versions: 6.2.3, 6.2.4 and 6.2.14
Second Server (apache with php 7.0.26):
typo3 versions: 7.6.14 and 8.7.1.
I'm not able to open the page on an iPhone or iPad with osx 10.x or above. I tested it on safari, chrome and firefox, but I get always an error like:
"[browser] can't open the page (...) because the server unexpectedly dropped the connection. (...)"
On a mac (osx 10), I get the error only in safari 11.0.2, but not in firefox or chrome.
I can open the pages without any problems, if I'm logged in at the typo3-backend with the same browser.
A Wordpress-Page is also running on the second server without any problems.
I have no problems on windows, android or other linux machines.
I tried the following without success:
clearing the typo3 cache
using the default .htaccess
using an empty .htaccess
The solutions from this site (german!): http://www.typo3forum.net/discussion/79617/ios-10-3-1-laedt-seite-nicht
Any ideas?
Have you tried to set the header content-length to 0?
https://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Config/Index.html#enablecontentlengthheader
Try to set the following lines to your TypoScript
config.enableContentLengthHeader = 0
You say you can open the page if you are logged in that matches the following description:
If the Backend user is logged in, this is disabled. The reason is that
the content length header cannot include the length of these objects
and the content-length will cut off the length of the document in some
browsers.

file_get_contents not working for local files, same issue with cURL

The problem:
file_get_contents('http://google.com'); works fine (works for any external url)
file_get_contents('http://my.server.org/existing_file.php'); returns nothing, and var_dump($http_response_header); returns an empty array when loading any local url.
I get the same empty response using 127.0.0.1 and localhost in place of the domain name.
I've tried/checked:
I've tried using cURL instead as suggested here - I get the same result (works for external URLs, empty response for local).
allow_url_fopen=On and cURL is enabled in php.ini according to phpinfo() - this must be ok, as I can load external URLs without a hitch.
I cannot use include instead, as I need to load a URL with variables to pass to a PDF renderer.
Is there some other php.ini setting that needs to change? Or could it be some other problem? I think it is a configuration issue because my code works fine locally in MAMP, but not on the production server.
Why I am doing this at all:
It's all tied up in a Wordpress functions.php file - I'm basically loading a url like http://my.server.org/path/to/file/?pdf-template, which I then check against the path to load the correct rendering template, which then feeds the rendered php to DOMPDF to generate a PDF file on the fly. Ultimately it means the client can append /pdf/ to any url in their wordpress site and get a PDF version.
What's odd is that this used to work fine on their server, and the person in charge of the server at the client says nothing has changed with the configuration. They have changed webhost in the last month though, which probably has something to do with it.
Update
I managed to pull this from the error log
Notice: file_get_contents(): send of 2 bytes failed with errno=104 Connection reset by peer in /home/path/to/my/file.php on line 19
The problem also appears to be intermittent - sometimes file_get_contents works, sometimes it fails with the above error. There doesn't seem to be a pattern.
Could this be a firewall problem?

Google PHP API library example: user-example: Firefox can't establish a connection to the server at localhost

Running Windows 7 Ultimate / Apache 2.4.9 / PHP 5.5.11 / FireFox 29.
When I try running the Google PHP API example user-example (using FireFox) I am able to connect and receive the approval page for the URL Shortener. However, when I click on the Accept button I receive the message:
"Firefox can't establish a connection to the server at localhost"
netstat showed that only Apache was listening on port 80. So, thinking that this might be a call-back issue, I ran a REST script (using the same credentials) that did pretty much the same thing, i.e. queried OAuth etc. This worked successfully.
NB: IE11 fails at the same point with a "This page can’t be displayed"
message, the offending URL being https://accounts.google.com.
Any assistance greatly appreciated.
Not sure if this will help, and its to big for a comment but try this
Changing the following PHP.ini settings:
Uncomment the extension=php_openssl.dll - necessary for 'https' URLs;
Set the time-zone. Google is fussy about times, so this might have affected the outcome.
I finally resolved the issue, much to my chagrin.
With all the other URI's in the example being "https://" I inadvertently set the call-back's URI to
https://localhost/etc
The solution was to set the call-back's URI to an 'http', i.e.
http://localhost/etc

Selenium Error while launching browser

I am facing two issues with Selenium.
1.- Error while launching browser on windows --> Example::testMyTestCase
Issues while capturing the screenshot:
Invalid response while accessing the Selenium Server at
'http://localhost:4444/selenium-server/driver/':
ERROR Server Exception: sessionId should not be null;
has this session been started yet?
Invalid response while accessing the Selenium Server at
'http://localhost:4444/selenium-server/driver/':
Failed to start new browser session: Error while launching browser
2.- I have used Selenium on Linux. While running the code with PHPunit, the browser windows opened get closed automatically. I need to watch the log details after the execution. Is there any setting required for this?
Please try to execute this script using latest Selenium-Server.jar (selenium-server-standalone-2.23.1.jar)

Selenium server doesn't work with page after it was redirected

I have a page which is like a splash screen. It performs some work and when it is complete it sends a request with ajax to main application. Main application should redirect to other page if everything is correct.
When I test it on selenium server, it doesn't work properly. It sends test failed after splash screen page. Like it doesn't see the redirection and can't search new contents for specified text.
UPD: Also it gives such error
PHPUnit_Framework_Exception: Response from Selenium RC server for getLocation().
ERROR Server Exception: sessionId should not be null; has this session been started yet?.
Try using browser with elevated security privileges, like *chrome for firefox
For the benefit of anyone else stumbling across this, I had a similar problem, but for me I had called setBrowserUrl with the wrong address - it was the address of my page under test, but it should be the base href of the site. So the 302 Redirect was actually set relative to the value I had passed to setBrowserUrl which landed me at an error page (despite the redirect working perfectly through a normal browser).
To fix the problem I called setBrowserUrl with the main site URL (where all relative links are relative to) and then called url in each test to set the page under test. This got things working again.

Categories