Closed LucasNCastro closed 2 years ago
Hey @LucasNCastro, interesting question! I'm wondering if your env
isn't set up correctly, because it says it's trying to connect via null
and not via singlestore
.
I believe Vapor injects DB_*
credentials into the environment, so it may be overwriting whatever you're trying to do.
Hey @aarondfrancis, thanks for your response.
Here is the database configuration and environment :
.env
DB_CONNECTION=singlestore
DB_HOST=*******
DB_PORT=3306
DB_DATABASE=*******
DB_USERNAME=*******
config/database.php
'connections' => [
'singlestore' => [
'driver' => 'singlestore',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST'),
'port' => env('DB_PORT'),
'database' => env('DB_DATABASE'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'unix_socket' => env('DB_SOCKET'),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => false,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
PDO::ATTR_EMULATE_PREPARES => true,
]) : [],
],
]
Maybe this can help you in analyzing the problem.
Can you tinker in your environment and dump out the config for me? I need to see what the actual evaluated config is inside of vapor. dump(config('database'))
(Of course redact your credentials)
Hey @aarondfrancis,
Exact same issue here, just keep getting this: SQLSTATE[HY000] [2002] (trying to connect via (null))
Been spinning my wheels on this for a few hours but narrowed it down to the singlestore driver, the moment you add it, it breaks the database in any vapor deployment
dump(config('database'))
PS; my config is under the mysql (I didn't declare a new connection called singlestore, but its essentially the same thing)
array:4 [ "default" => "mysql" "connections" => array:4 [ ...... "mysql" => array:15 [ "driver" => "singlestore" "url" => null "host" => "svc-top-secret-uuid-dml.aws-virginia-3.svc.singlestore.com" "port" => "3306" "database" => "my_singlestore_db" "username" => "username_as_specified_in_.env" "password" => "password_as_specified_in_.env" "unix_socket" => "" "charset" => "utf8mb4" "collation" => "utf8mb4_unicode_ci" "prefix" => "" "prefix_indexes" => true "strict" => false "engine" => null "options" => array:3 [ 1009 => "/var/task/rds-combined-ca-bundle.pem" 20 => true 12 => true ] ] .....
Just another note, changing back to mysql driver doesn't fix it. Seems to break soon as you add the package in composer
It's weird, it looks like it makes vapor shit the bed, I had to delete and recreate the vapor project to get it to work again (without the laravel / singlestore driver).
Not much help but I also experienced this when trying to use this driver on vapor.
The config when DD'd from tinker all looked correct through vapor to me as well.
Also just like above switching my config back to mysql isn't solving it but it definitely all worked until I pushed a commit with this driver.
This is so strange. We use this package in Vapor without any issue, with PHP 8.1+layers, PHP 8.1+Docker and even PHP 8.0+layers.
Are you guys using managed or self hosted SingleStore?
Super bizarre. I'll spin up a new vapor app and try it on Tuesday, let me know if y'all figure anything else out before then! Sorry for the weirdness
@aarondfrancis There is output dump(config('database'))
:
"default" => "singlestore"
"connections" => array:6 [
"singlestore" => array:15 [
"driver" => "singlestore"
"url" => null
"host" => ****
"port" => "3306"
"database" => ****
"username" => ****
"password" => *****
"unix_socket" => null
"charset" => "utf8mb4"
"collation" => "utf8mb4_unicode_ci"
"prefix" => ""
"prefix_indexes" => true
"strict" => false
"engine" => null
"options" => array:2 [
1009 => "/var/task/rds-combined-ca-bundle.pem"
20 => true
]
]
I also updated singlestoredb/singlestoredb-laravel
package to use version 1.0.0.
No success, I got the same error on Vapor Serverless.
@fgilio I use managed SingleStore.
This is so strange. We use this package in Vapor without any issue, with PHP 8.1+layers, PHP 8.1+Docker and even PHP 8.0+layers.
Are you guys using managed or self hosted SingleStore?
managed
Update: I've now been able to emulate this without the Laravel SingleStore driver (when trying to store sessions to DB)
Switched session to Redis problem went away
Interesting!
I was going to ask if you guys are adding the singlestore_bundle.pem
certificate in your codebases, since I had similar issues when I first started using the package and all I was missing was the certificate.
I just remembered that and I don't remember talking about it in any other issue here in GitHub 🤔 , @aarondfrancis I'll see if I can draft a PR about it this week.
Will try in the morning and let you know, thanks for the suggestion
I couldn't resist and had to test. It's the certificate, it fixed it. Thank you!
Wohoo! Happy to know it worked, the error is very misleading
Yep worked for me too! Thank you!
@aarondfrancis and the rest of the people on this thread - are there particular things we should add to the readme to improve this?
Hi,
The singlestore driver seems incompatible with Vapor.
From a middleware where we do this :
auth()->check() === false
Here is the error received :
Even trying to register singlestore connection in the
AppServiceProvider
following this issue : https://github.com/singlestore-labs/singlestore-laravel-driver/issues/2 it does not workMaybe an extension is missing on Vapor but which one? Is there an incompatibility with Alpine?
On EC2 it works but not on serverless :(.
Any idea?