ERR_CONNECTION_RESET with symfony2 but not with PHP script - php

I am currently developing a web application with Symfony that's supposed to connect to a remote Web-Service. Then synchronise database from the client to the server and vice-versa and some other crap.
The Web-service server is on an IIS in the LAN.
Symfony2 is running with Wamp on my machine.
So, the connexion and request code to the web-service in a simple php script is perfectly functional. Or at least, it does what I want it to do.
And any connexion to the IIS server is perfectly fine.
A bit slow though, but the machine is quite a mess.
Now I put that same code into a Symfony2 class, and here comes the hell.
When I try to load that page, I get a
101 error (ERR_CONNECTION_RESET)
Web-service server's log indicates me that the login, request and response were sent.
So my guess is the problem is comin' from my machine, but not quite sure about it.
The really funny thing : I somehow managed to make it work for about 10 times.
Then 101 again...
I disabled the Windows 7 LAN firewall both side, same result.
Any clue is very welcome.
Thanks.

I spent hours debugging this with a colleague. He was getting the same error but it was working properly on my machine (we're using Windows 7, 64bit, WAMPServer 2.2d, 32bit).
Here is what the culprit was:
- the file TwigEngine.php had Unix-style line endings (LF) on my machine but on his machine it had Windows-style line endings (CR+LF)
- after changing the line endings to LF only, it works fine on his machine too
That would possibly explain the other answer above "all I needed to do is just resave
TwigBundle/TwigEngine.php" if the editor changed the format of the line endings.
The underlying cause was the installation of git, he had picked the default ("Windows-style check-outs") and I had selected "as-is").
After some more research. here is an explanation of the cause for this: https://github.com/symfony/symfony/issues/3216
Hopefully this helps someone else save some time.

I solve the problem...
I set the second parameter of AppKernel in app_dev.php to FALSE and now works fine
$kernel = new AppKernel('dev', FALSE);
I will continue investigating...

I had same problem after 4 hours of "debuging" i found that all I needed to do is just resave
TwigBundle/TwigEngine.php
I have no clue why

In fact, I think (in my case at least) those errors are twig related.
Sometimes, when there's a critical error related to twig logged in app/logs/dev.log, I got that 101.
Those critical errors are often syntaxic, so no real deal here.
And once they are dealt with, no problem anymore.
The strange thing is that sometimes, clearing the cache allows me to load the page 3 or 4 times.

Mike WP made it. TwigEngine need LF line endings to work properly. You can use this console command then you'll have to update/reinstall vendors.
git config --global core.autocrlf input

I had the same issue on Windows using XAMPP, and solved by:
composer require "twig/twig:^2.0"

Related

Warning: class_implements(): Class does not exist and could not be loaded

Not sure if this question belongs here, but it is kinda a programming question.
I'm running xampp 3.2.2 (just Apache and MySQL) with php 7.1.14 on Windows 7 to work on several Symfony (2.8) applications.
Initially I had them hosted with vhosts using different ports and accessed them by http://my-ip:port, but that was a PITA because 1) the browser mixes up the cookies, forcing you to continually log in when switching apps and 2) some php cache (I think, its been a while) mixes up User classes, forcing you to restart Apache.
I then switched to name-based vhosts (nothing fancy, local name resolution using C:\Windows\system32\drivers\etc\hosts) which got rid of the issues.
Not sure if it is related to running several apps, but now I got a new problem: Everything started out fine, but then Symfony sporadically threw this error in my face:
Warning: class_implements(): Class does not exist and could not be loaded
Most of the time there is no class name (note the two spaces), sometimes it says some gibberish like \.php$. I typed this one from memory, but I think it was a less well-formed regex. I also get other stuff that's definitely not a class name.
Over time (a few weeks), "sporadically" changed to "every few minutes/requests", even with just using one app. What helps is restarting Apache, sometimes I also need to delete the Symfony cache.
What is going on here and how can I fix it?
this works for me:
in php.ini file
change this line,
;realpath_cache_size = 4096k
to
realpath_cache_size = 4096k
and restart your Apache or XAMPP.
This error was occurring in my Localserver, i just restarted the Apache and things become fine. So, you can make a try.

Sugar CRM saves index.php file after migrating to new server

i transferred a website over to a new server. as far as i can tell, everything came with it. databases, SSL, everything. It was a cpanel package script:
/scripts/pkgacct fileserv
its Sugar CRM. it still works on the old server, but when i try to use it on the new server, it just downloads index.php
and leaves me at a blank screen. any ideas? i was thinking possibly a PHP or Apache module or something, but I've never set up sugar CRM myself, and in setup guides, i couldn't find any special modules or anything that I need.
this is a problem i've dealt with before, but all the typical fixes aren't working. there are other websites running, so PHP and apache are working just fine. I edited .htaccess and everything too. but any suggestions at all would be very helpful. assume i've done absolutely nothing so far, just in case I missed something obvious.
Yeah it's probably apache, either A) the new server does not have PHP installed and apache does not have the module installed either or B) apache does not have the module installed to execute php scripts.
I think the comment under your question is heading in the right direction:
PHP code is not being executed, instead code shows on the page

Symfony2.4 forms working on local computer but not on distant server

I'm having a frustrating problem with all the forms of a Symfony2 website for a couple of days now.
In fact, every form are OK when my coworkers and I work on the project on our local computers (we're all on PC, Windows 7 64bits or 8.1 64bits, using WAMP 64bits too and having PHP v5.4 and Symfony v2.4.3 set on it). But when we want to test on our distant dev environment, there is no form that works properly: in the Symfony profiler, the problem seems to reside in the fact that no POST parameters go through the process of submitting the form. But once again, this situation only appears when the project is hosted on the distant server.
I have checked the configuration of the server because I thought it was a config issue, but everything looks just the same as what we have on our WAMPs.
I have also checked my config.yml file, just to see if something could be wrong in it, but I can't see any kind of "local-only" configuration.
Moreover, I've found a very few people telling that they encountered the same problem on the internet, but they never explained how they did to go through that.
As I said, I am currently on this issue for days now, and every suggestion and clue will be very welcome!
Thank you for your time,
[Edit 1] This is a complementary information: the only difference between our local and remote configuration is that, on the remote server, the "short_open_tag" thing is enabled and, due to some provider restrictions, can't be disabled.
So I enabled it on my WAMP (and restarted it) to see if to see if the forms would keep working. And they do work with short_open_tag enabled on my local machine, so I assume that the problem is not from there.

file_get_contents with https gives weird first character

Trying to debug a composer error that's happening on my windows machine and not my linux server. Here's the code I'm trying to execute
$url = "https://packages.zendframework.com/packages.json";
var_dump(file_get_contents($url));
When I execute this, I get something like: http://grab.by/pSFI
As you can tell, the weird utf8 character at the beginning should not be there. It does not happen with non-secure protocol (but this url with 301 to secure anyways, so it's not possible to demonstrate).
Any ideas? Is it an openssl dll issue?
This was a windows setup issue that was solved by using xamp instead of wamp. There is a bug in the php build used by my wamp instance that would mess up file_get_contents on ssl destinations. It is working correctly after switching to xamp.
These steps would usually do the trick as they are the only reasons I can think of offhand where I've seen that character.
Open your file.
Make sure it has UNIX line endings.
Trim the white space on save.
Make sure there is nothing before the first character. ( Hit backspace for fun before first character, if you don't see anything, in case a control character somehow got copy pasted in that you can't see )
Make sure your server is returning UTF-8 encoded headers
Also, do not develop in different environments... all of them should match. There can be plenty of quirks that are different between different systems. I even had memcache issues on one environment, but not the other, before we got all environments synced. Even worse, you might not see a bug on your dev environment that pops up in production... and then you won't be able to debug it.

PHP has encountered an Access Violation at 77FCAFF8

I am running a PHP site that uses Ajax and jQuery as well. The site will run fine for quite some time, and suddently my pages (and ajax-retrieved sub-pages) comes back with the message
PHP has encountered an Access Violation at 77FCAFF8
It seems that rebooting the server corrects the issue. Running PHP Version 5.1.6 (Windows NT 5.0 build 2195). I did a some searching on here and some other sites, and there seems to be no fix..
URL REMOVED
UPDATE:
I think I'm on to something.. will get back to you.
UPDATE
After reviewing the IIS setup, i noticed there was no Handler Mapping setup for the website. This, of course begs the question - how did it ever work in the first place, when it was originally setup this way!? I added the handler mapping and it seems to be Okay so far.
UPDATE
The problem popped its heads out again this morning after 36 hours without encounering it. Back to the drawing board.
UPDATE
We ended up just moving the site to a secondary web server where we were able to upgrade PHP without an issue.
This is a PHP issue somewhere. You could spend some time narrowing down which function you're using that is causing the problem. I would instead upgrade to a newer version of PHP. If still no luck, try a slightly older version. There have been significant changes with version 5.3.2.
After some research I think this may be the solution (Taken from http://bugs.php.net/bug.php?id=28929 ):
[2010-06-11 15:12 UTC] in2ishun at yahoo dot com
***************** SOLUTION!!!!
I realize this issue is AGES old, but it still manages to be the top hit on Google searches as of now (6/2010).
I fixed my own instance of seeing this error. W2k3, IIS6, PHP 5.2.6, MySQL 5.1.
The problem is in the pathing. When I used the MSI installer for MySQL without doing an "advanced" installation (where I could manage the install details), it added a path to the system environment that contained spaces. Even after changing the path environment to use the Windows short-name location of the mysql bin directory, it still didn't work.
The solution was for me to reinstall mysql and set the default installation path to just off the root (e.g. C:\mysql). Once I did that the error went away and my app started working.
There are a number of sites with a variety of potential solutions to this issue and several of them mentioned paths and the "libmysql.dll" file (in the "bin" directory of your mysql installation).
If this helps you solve your problem, consider leaving a comment here so others can see that it works.

Categories