Redis server connection error in laravel v4.2 - php

Hi I working in laravel v4.2. Now I want to send push notifications to users in queue so for this purpose I use redis server for queue push notifications. But the problem is that I want use the redis server of of other server instead of home/local server. Is there any solution to solve this problem. Below is my queue.php file configuration that I am using
'redis' => array(
'driver' => 'redis',
'queue' => 'default',
'cluster' => true,
'default' => array(
'host' => '192.168.1.244',
'port' => 6379,
'database' => 0,
'password' => ''
),
If I use my own pc IP address then I receice queue notification but when I try to use the other pc redis server then I receive following error in exception
Connection refused [tcp://127.0.0.1:6379]
Please let me know if anyone know that how to cofigure or user redis server remotely.
Thank you

I found the issue issue in my code I was doing configuration in queue.php instead of database.php file. So when I change the host in database.php file then I become able to work with redis server.

Related

Copy or create file on remote FTP

So, I have tried 4 different ways of doing this, none of them worked.
There's a 3rd party server that I can create and delete files on via Filezilla. This was for testing purposes however.
There's a script on my Laravel application that'll run once a day, create a few XML files and those need to automagically transfer to that same server.
When I create an ftp filesystem I get the error "ftp_rawlist(): php_connect_nonb() failed: Operation now in progress (115)" after a timeout.
When I try PHP's ftp_put or ftp_fput I get the error "ftp_put(): php_connect_nonb() failed: Operation now in progress (115)" (or ftp_fput, same error).
When I try PHP's fwrite with the ftp as a destination I get the error "failed to open stream: operation failed". This also fails in the browser.
I have made sure credentials are correct. I've copy/pasted them from the working Filezilla connection details.
Filesystem code:
'ftp' => [
'driver' => 'ftp',
'host' => env('FTP_HOST'),
'username' => env('FTP_USERNAME'),
'password' => env('FTP_PASSWORD'),
'root' => '/Production',
'ssl' => true,
'ignorePassiveAddress' => true,
],
I know about the server behind NAT problem, but it won't accept my changes to use original address in filesystems. I've cleared cache, and config and fed the hamsters, but nothing changes.
I'm honestly at the end of my knowledge right now. And asking the 3rd party to change their configuration/settings isn't an option. This server is one of many and they're all exactly the same, but different clients. They might help me by providing the logs on their end, but that's about it.
The only other that I see which could be a difference is that I'm running this code from command line (ie, as if it's run via cron). Not sure if that causes problems with connecting and creating files on a remote server. I'm not that experienced with writing Laravel commands.
Any help would be greatly appreciated.
Ok.
Ok. Inside the configuration file like this:
'ftp' => [
'driver' => 'ftp',
'host' => 'ftp.example.com',
'username' => 'your-username',
'password' => 'your-password',
'passive' => 'false',
'ignorePassiveAddress' => true,
'port' => 21,
]
add file 'test.pdf' inside the ftp
simply run
$contents = \Storage::disk('ftp')->exists('test.pdf');
dd( $contents );
and it works.

Laravel app hosted on Heroku with a Amazon RDS MySQL Database results in a connection time out

I have a Heroku app where I'm hosting my Laravel app. I started the development initially with MySQL, so I wanted to continue doing so using Amazon's RDS service. I create the instance there and managed to successfully connect via my MySQL client, the console etc.
The problem is that the Laravel app can't connect the database after numerous desperate attempts for me to fix it. I have found some articles suggesting the use of DATABASE_URL environment variable is mandatory, so I added it via the Heroku app settings. It looks like so:
mysql://myusername:mypass#myhostnamefromamazon/mydb?sslca=/app/storage/certs/amazon-rds-ca-cert.pem
I found this solution on Heroku's website. I have placed the amazon-rds-ca-cert.pem file on my Laravel's storage folder, like so: /app/storage/certs/amazon-rds-ca-cert.pem
This didn't solve my issue, so then I kept looking and found a Stackoverflow question which had this issue on Lumen. I adjusted my config/database.php according to the answer, but it's still not working for me!
<?php
$credentials = get_db_credentials();
$config = [
'default' => env('DB_CONNECTION', 'mysql'),
'connections' => [
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', $credentials->host),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', $credentials->database),
'username' => env('DB_USERNAME', $credentials->username),
'password' => env('DB_PASSWORD', $credentials->password),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
],
];
if (env('APP_ENV') == 'production') {
$config['connections']['mysql']['options'] = [PDO::MYSQL_ATTR_SSL_CA => '../storage/certs/amazon-rds-ca-cert.pem'];
}
return $config;
The get_db_credentials() function simply parses the DATABASE_URL environment variable.
The exact exception that I get is:
[2018-10-25 19:32:16] production.ERROR: SQLSTATE[HY000] [2002] Connection timed out {"exception":"[object] (Doctrine\\DBAL\\Driver\\PDOException(code: 2002): SQLSTATE[HY000] [2002] Connection timed out at /tmp/build_05920c42a6de0a378402b798320d3f04/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:50
I'm totally lost on this and unsure how to proceed.
Your AWS Security Groups must permit traffic from Heroku's IP address range.
https://devcenter.heroku.com/articles/amazon-rds
You must grant Heroku dynos access to your RDS instance. The recommended way to do this is to configure the RDS instance to only accept SSL-encrypted connections from authorized users and configure the security group for your instance to permit ingress from all IPs, eg 0.0.0.0/0.

Error while trying to connect to an external DB server from Google App Engine

I have a scenario where for a certain reason I cannot use Google's Cloud SQL. Hence I want the application at appid.appspot.com to connect to an external DB server.
DB.php
'hostname' => '202.202.202.202',
'username' => 'user',
'password' => 'password',
'database' => 'dbname',
'dbdriver' => 'mysql',
This gives me a Server Error, however I'm able to connect to the database from mysql workbench. This application does not have a problem while connecting to Cloud SQL.
Error message:
Error: Server Error
The server encountered an error and could not complete your request.
Please try again in 30 seconds.
Can someone help me understand where I'm going wrong.
I did the following changes and got it working.
Instead of IP address I gave the external DB server a hostname.
'hostname' => 'dbserver.example.com',
'username' => 'user',
'password' => 'password',
'database' => 'dbname',
'dbdriver' => 'mysqli',
Then I activated billing for the Google App Engine project. Once you activate billing the Google Socket API will start functioning.
Please do not try immediately. Give it sometime and this should start working just fine.

Can't connect to database with laravel 5

I'm trying to connect to my mssql database with laravel 5 but it's not working. I've tried to connect with different mssql databases so it's not a firewall issue. Also my credentials are correct. I found on google that you need SQL Server Native Client 11.0 and I've already installed that.
This is my connection array in config/database.php:
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('nvt'),
'database' => env('nvt'),
'username' => env('nvt'),
'password' => env('nvt'),
'charset' => 'utf8',
'prefix' => '',
],
And I've set the default to "sqlsrv" :
'default' => env('sqlsrv','sqlsrv'),
But when I'm trying to create a table I receive the error:
PDOException in Connector.php line 50: could not find driver
What could be wrong???
EDIT:
I've installed pdo for sqlsrv from here:
http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx
And I added it to my php.ini file:
extension=\Installaties\php_pdo_sqlsrv_53_nts.dll
But stil I receive the error?
Try to remove the eve() method, i mean use the following method
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => 'nvt',
'database' => 'nvt',
'username' => 'nvt',
'password' => 'nvt',
'charset' => 'utf8',
'prefix' => '',
],
I ran into a similar issue. Try putting in the server info directly rather than using env. If it works, then you know Laravel is having an issue reading the .env file.
I encountered your problem the last time I tried my connection in sqlsrv. I am using xampp. Try putting yung php_pdo_sqlsrv_53_nts.dll in the ext folder, replace extension=\Installaties\php_pdo_sqlsrv_53_nts.dll with extension=php_pdo_sqlsrv_53_nts.dll and try installing odbc 11 on your computer. It worked for me but not sure why. (not an expert) if it worked good to help a fellow person and if not, sorry for the trouble. Thank you for the time reading.
You may try any of the following solutions
Check that you have entered the right connection parameters. Test by connecting to the DB with a client tool.
Make sure you have the right version of sqlsrv configured for your machine. Check the PHP logs to be sure your web server was able to load the extension correctly.
Set the port to null in your env file
As a tip, I won't advise anyone to set the connection parameters anywhere but in the .env (Setting it in config/database is a security risk).

SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (severity 9) Laravel

I'm getting this error when trying to connect to an SQL Server DB from Laravel 4.2.
Here's my DB config:
'connections' => array(
'sqlsrv' => array(
'driver' => 'sqlsrv',
'host' => 'example.noip.me',
'database' => 'db',
'username' => 'sa',
'password' => 'pass',
'prefix' => '',
),
),
//...
It works perfectly in my home computer, but not in production. This project is in a hosting service, so I can't change much of the config (can still use ini_set though).
I tried adding the port to the server address but it didn't work.
Edit: I forgot to mention that the hosting and the database server are on different computers, so it could be a security configuration problem.
I contacted tech support and it turned out to be a matter of configuration in the hosting server (Remote Database Access Hosts, which I thought was for MySQL only).

Categories