One of my application suddenly started to give error:
Fatal error: Uncaught exception 'RedisException' with message 'Redis server went away' in /var/www/_slim/_core/system/generator.001.php:133 Stack trace: #0 /var/www/_slim/_core/system/generator.001.php(133): Redis->auth('77B1BFFBC0378DF...') #1 /var/www/_slim/_core/system/generator.007.php(144): Generator001->r6_redis_start('R') #2 /var/www/_slim/_core/system/generator.007.php(26): Generator007->HarvestRedis() #3 /var/www/_slim/_core/system/generator.shopping.php(14): Generator007->Generator007() #4 /var/www/_slim/_core/system/generator.last.php(43): Generator008->Generator008() #5 /var/www/_slim/site/home/php/index.php(16): GeneratorLast->GeneratorLast() #6 /var/www/index.php(96): Gui->Gui()
#7 {main} thrown in /var/www/_slim/_core/system/generator.001.php on line 133
I have reinstalled redis-server but no luck so far. Any suggestions?
Maybe not the answer to the specific question, but might help those new to Redis who come here by googling the Exception.
You will also get this exception if you create a Redis instance and start to call methods on it without first connecting to a Redis server by calling
$redis->connect('localhost')
The arguments for the call should obviously be adjusted if Redis is not a local host, configured to listen on a different port, set up a password etc.
Well, as the exception describes itself, your Redis server is down.
Try the following stuff:
See if the server that runs the Redis instance contains any firewall on (iptables, maybe?).
Go to your web server (that runs your php) and try to telnet to your redis server.
See if the configured host/ip is correct. Maybe something in the network settings of the Redis server have been changed.
I had a problem connecting to the redis
I managed to solve it by changing the colon to a comma
$redis->connect('localhost:6379');
from this to this
$redis->connect('localhost', 6379);
If you are running on a local/dev environment, make sure that Redis Service is running.
You can check if your local service is running by opening the Redis Client cmd. If you are on a MAC open the command line and type redis-cli.
If your server is running you should see:
redis 127.0.0.1:6379>
In my case I forgot to start the windows service so all I had to do was to: open services.msc, start Redis Server service.
I've had the same issue when integrating my software with local Redis installation. Turned out "localhost" host name was not resolved (stuff was was running in a docker container which didn't know that). Changed it to regular loopback IP "127.0.0.1" in the client config and it rolls.
My issue was that I was using Docker Compose and needed to use the name of the container instead of 'localhost'.
// Connect to the Redis Docker created server. 'redis' refers to the
// 'redis' container in the docker-compose.yml file.
$redis->connect('redis');
// docker-compose.yml
redis:
image: redis:alpine
volumes:
- redis-data:/data
ports:
- ${FORWARD_REDIS_PORT:-6379}:6379
healthcheck:
test: ["CMD", "redis-cli", "ping"]
networks:
- default
Related
First situation:
I run the php artisan migrate command from a terminal on a laravel project, and it works fine updating the mysql database on
127.0.0.1:3306. This means that the php-mysql connection was fine.
Second situation:
Running the project inside a docker container I was not able to set
the database to 127.0.0.1 since in a docker container that matches
the container itself. I read that docker has a bridge to connect
with the host (in the case of Linux 172.17.0.1). So I changed the mysql
connection settings to 172.17.0.1:3306. And I get:
PDOException
Packets out of order. Expected 0 received 1. Packet size=69
and
PDOException SQLSTATE[HY000] [2006] MySQL server has gone away.
Question:
Why does it work with 127.0.0.1 but from not from inside a container?
i am trying to install Laravel Echo Server on Laravel 5.5 with the help of thie Article
https://medium.com/#dennissmink/laravel-echo-server-how-to-24d5778ece8b
All things is going right but when i
laravel-echo-server start
Error comes with
[ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379
at Object._errnoException (util.js:992:11)
at _exceptionWithHostPort (util.js:1014:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
i install laravel 5.6 but still i face the same error
Thanks in advance who can guide me how can i handle this error
Seems like Redis is not installed or the Redis server is not running.
Download and install the server from https://redis.io/
And then run the service with "redis-server".
After that you can smoothly run "laravel-echo-server start"
make sure that redis listen on 127.0.0.1:6379.
look at /etc/redis/redis.conf, the line where is indicated "bind ....". make sure it's "bind 127.0.0.1" otherwise go to your laravel-echo-server.json and change databaseConfig: {redis: {port: "6379", host: "..."}}.
"..." indicating what is marked in redis.conf
Make sure you have install radis server
sudo apt install redis-server
This error occurs with all Vagrant boxes with a private network IP.
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["hostonlyif", "create"]
Stderr: 0%...
Progress state: E_FAIL
VBoxManage.exe: error: Failed to create the host-only adapter
VBoxManage.exe: error: Code E_FAIL (0x80004005) - Unspecified error (extended info not available)
VBoxManage.exe: error: Context: "int __cdecl handleCreate(struct HandlerArg *,int,int *)" at line 66 of file VBoxManageHostonly.cpp
I've tried composer install, manual install, downgrading virtualbox to 4.2.x - nothing works.
Please help!
Thanks
Turns out to be a common 'issue' on Windows 7 hosts with any vagrant box with a private network.
The Windows host user account needs to have admin rights.
There's a known bug # 14040 in VirtualBox 5. Updating to Vbox 5.0.9 worked for me.
I had the same problem using virtualbox 5.0.26 when I updated to 5.1.4 it worked! am using vagrant version 1.9.1
I'm trying to run some functional tests using phpunit in Symfony2.
When I run my test, I get this error:
PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock)
I'm assuming phpunit cannot find my mysql socket, though I have set it in my php.ini file (in MAMP.) My web application works fine in my browser and succeeds in connecting to the database.
I've tried adding this setting to my phpunit.xml.dist file but I get the same result:
<php>
<ini name="mysql.default_socket" value="/Applications/MAMP/tmp/mysql/mysql.sock"/>
<!--<server name="KERNEL_DIR" value="/path/to/your/app/" />-->
</php>
Is there any way to verify/ change the php.ini file that phpunit is using?
If that's not the problem, then let's go back to square one. Here's the test I ran:
class VBMTest extends WebTestCase
{
var $container;
public function setUp()
{
$client = static::createClient();
$client->getKernel()->boot();
$this->container = $client->getContainer();
}
public function testNameNotFound()
{
$form = array('lastname'=>'Jones','sex'=>'F','day'=>'5','month'=>'5','year'=>'2005');
$vbm = $this->container->get('tk.vbm');
$vbm->init($form, 'process_app');
$step = $vbm->getStep();
$this->assertEquals(
'register',
$step
);
}
}
I added this line, in case the testing app wasn't loading all of my parameters. (I'm new to testing in Symfony2.)
$client->getKernel()->boot();
config_test.yml imports config_dev.yml, so I don't see why my database settings would not be included in my testing configuration.
UPDATE
I tried uninstalling phpunit and reinstalling it using Composer as mentioned here~ Installing PHPUnit on MAMP 2.1.3 (Mountain Lion).
So now I run my phpunit command with bin/phpunit.
Still -no change in the outcome. I still receive the "PDO::__construct(): [2002] No such file or directory" error.
UPDATE II
As I mentioned below - responding to #Udan's suggestion - I changed the config settings in my config_test.yml file to change the host to 127.0.0.1:
doctrine:
dbal:
driver: pdo_mysql
host: 127.0.0.1
port: 3306
dbname: test_tk
user: test_tk
password: ############
charset: UTF8
I even added a new user and a new database for testing (test_tk). The error changed, but I still can't test my application.
ERROR 1045 (28000): Access denied for user 'test_tk'#'localhost' (using password: YES)
Here's a synopsis of my user's privileges from phpmyadmin:
User: test_tk
Host: %
Type: global
Privileges: All Privileges
Grant: Yes
There is something screwy going on with my mysql installation. I used to be able to connect to mysql through the command line. And now I cannot. Strangely - the web app still connects just fine through a web browser.
Which brings me back to the heart of the original question. Why does my application successfully connect to the database through a web browser, but not through phpunit?
Any other helpful hints out there?
Does phpunit use a different php.ini file than the one configured in MAMP?
Yes, the command line version of PHP usually has it's own version of php.ini. Run php -i to get the phpinfo and have a look at which INI is used there.
For using TCP on the local machine you have to use 127.0.0.1 as hostname and not localhost in new PDO("mysql:host=127.0.0.1;.....");
I have such network configuration (see link - http://s58.radikal.ru/i160/1110/4c/1c2c5d74edd0.jpg)
Where:
Notebook - contain Apache+php+mongodb+php drivers for mongodb+web project on Zend (Windows)
router - virtual station (nat on 192.168.5.23 interface + ipfw)
natd.conf:
interface le0
same_ports
use_sockets
redirect_port tcp 192.168.5.23:27017 27017
redirect_port tcp 192.168.5.23:27017 27017
ipfw:
allow from any to any
virtual station 2 - contain ONLY mongodb (no php, apache, or mongodb php drivers )
1 - ping from notebook to mongodb host and backward - works.
2 - shell on virtual mongodb host: mongo 192.168.5.20:27017 - connected to notebook's mongodb successfully
3 - attempt to connect from notebook to virtual host cause such error:
C:\mongodb1.8.2\bin>mongo 192.168.9.21:27017
MongoDB shell version: 1.8.2
connecting to: 192.168.9.21:27017/test
Sun Oct 02 22:31:14 Error: couldn't connect to server 192.168.9.21:27017 shell/mongo.js:81
exception: connect failed
4 - attempt to use remote host with DB in php project (www.vm.lcl):
an exception occured while bootstrapping
connecting to vm-db1.lcl failed: Unknown error
Stack Trace:
#0 C:\www\vm-db1.lcl\library\Zirrk\Database\MongoConnection.php(16): Mongo->__construct('vm-db1.lcl')
Please, give me advise - in what direction should I search my mistakes!
Thank a lot!
I've solve this problem by changing rule in natd.conf
redirect_port tcp 192.168.5.23:27017 27017
to
redirect_port tcp 192.168.5.23:27017 192.168.9.21:27017
Before understanding how to fix it, I've create in virtual network (192.168.9.0/24) web-server (192.168.9.11) with apache+php+mongo-php-driver (mongodb - was not installed), and tried to connect to 192.168.9.21
$m = new Mongo("mongodb://192.168.9.21:27017");
This was no sense. I've spent whole day in brainstorm and googling information, but still nothing. (Error was in timeout while connection to server). Then I rest for few hours, and understand, that in my case, all traffic goes through Freebsd-gateway host and add to natd.conf
redirect_port tcp 192.168.9.11:27017 192.168.9.21:27017
reboot gate-way server, and it come to work!