"SQLSTATE No such file or directory" Error When Server Actions are Invoked on Production Server

Wappler 3.0.0 rc2

I’ve uploaded my design to my AWS server in the way I normally do, but this time none of my server actions which access the database are working… I’m getting the following message:

server

Below is the detail of the trace.

All the files it mentions are present on the server…

I can log into the database okay from the server…

Can someone point me to what the issue may be please?

Thanks,
Antony.

#0 /var/app/current/dmxConnectLib/lib/db/Connection.php(81): PDO->__construct('mysql:host=loca...', 'root', '', Array)↵
#1 /var/app/current/dmxConnectLib/modules/dbconnector.php(12): lib\db\Connection->__construct(Object(lib\App), Object(stdClass))↵
#2 /var/app/current/dmxConnectLib/lib/App.php(173): modules\dbconnector->connect(Object(stdClass), 'db_write')↵
#3 /var/app/current/dmxConnectLib/lib/App.php(137): lib\App->execSteps(Object(stdClass))↵
#4 /var/app/current/dmxConnectLib/lib/App.php(107): lib\App->execSteps(Array)↵
#5 /var/app/current/dmxConnectLib/lib/App.php(72): lib\App->exec(Object(stdClass))↵
#6 /var/app/current/dmxConnect/api/prices/update_price_contact_list.php(8): lib\App->define(Object(stdClass))↵
#7 {main}

The error message indicates that a MySQL connection via socket is tried (which is not supported). Try changing localhost to 127.0.0.1 in your database connection.

btw. How did you upload your files to the server? Did you switch to the correct target first in Wappler?

Hi Patrick…

This is a route I have used for the past few months and has worked okay, so I am trying to work out what has changed…

I am using AWS Elastic Beanstalk with a separate RDS server for the MySQL database… so the database target is the address of the RDS server, which I haven’t changed.

To upload, I set the target to AWS Production in Wappler, then create, upload and deploy a .zip file.

On the server I’ve done a cat of .wappler/project.json and the active target is correct.

I can log into the EC2 server and then log into the MySQL database from there - that all works okay. The database is only accessible from the EC2 server.

I’ve not changed any AWS settings for a while.

So is the message saying that Wappler tries to make the connection “via socket” and the database replies and says “Sorry, I don’t do connections via socket”?

Has anything changed in Wappler which could effect how this works? I last did a successful upload about 3 weeks ago probably using Wappler 3.0.0 b3. I’ve re-deployed that version of the design and everything works okay!

The activate target setting is for within Wappler only - it does nothing on your server.
It is also not smart to deploy your .wappler folder to your live server as you also have all the security settings in there. You should exclude it from the zip file.

on your live server the database connections are used as listed in dmxConnect/modules/Connections
So there you will find your connection on your live site.

In the .wappler folder we store the different connections settings per target, in .wappler/targets/__target_name__/files/dmxConnect/modules/Connections

So when you just switch active connection in Wappler the only thing that happens is that the target specific files from .wappler/targets/__target_name__/files/dmxConnect/modules/Connections get copied to dmxConnect/modules/Connections

So when deploying then all the current connection settings are in the dmxConnect/modules/Connections

Thanks for that input @George!

So to be clear…

In the connection_name.php file found in dmxConnect/modules/Connections, I will just find the connectionString for one database. Is that correct?

And that database should be the one I last selected in Wappler by setting the Target?

Because in the connection_name.php file on the server, it lists the connection to my local database on my laptop. However I had definitely set the Target in Wappler to be AWS Production before creating the zip file. It is still set in Wappler from when I did that a couple of hours ago.

So as well as setting the target to be AWS Production in Wappler, is there something else I need to do before creating my zip file which will set the right database target in the Connections folder?

I’ve just tried toggling the target button in Wappler between “AWS Production” and “AWS Test”, but the content of the connection_name.php file on my laptop is always pointing to the database on localhost.

Is it possible this is a bug in 3.0.0 rc2 which is the release I am still on at this moment?

I’ve just checked that the files in the .wappler/targets/__target_name__/files/dmxConnect/modules/Connections folder seem to have the right information in them…

yes, exactly. each php file in that folder is for single database

yes

well that is where you got it wrong … and the danger of manual publishing.
At least now you now where to check before the publish

Maybe your connections aren’t setup well per target? Che the server connect connection settings when you switch targgets and also the generated files in the .wappler/targets folders - so it is all fine.

I’m not sure what you mean by that George… what did I get wrong?

Is it correct that when I switch target in Wappler then the dmxConnect/modules/Connections/connection_name.php file should contain a ConnectionString to the target I just chose?

Because this isn’t happening, even though I have the correct information in the .wappler/targets/__target_name__/files/dmxConnect/modules/Connections/connection_name.php file.

And this used to work, as I’ve just checked the dmxConnect/modules/Connections/connection_name.php file of some of my previous deployments…

Also George…

What do you think to the idea of me just writing a target specific config script in my .ebextensions folder to copy the

.wappler/targets/__target_name__/files/dmxConnect/modules/Connections/connection_name.php

to

dmxConnect/modules/Connections/connection_name.php

?

Then I wouldn’t need to worry about changing the target correctly each time before I deploy…

well that is up to you

Hi George…

Could you let me know the answers to my post before please?

I’m facing this same issue when I try to edit a serverside action from within wappler, connecting to my development nas that uses a 127.0.0.1 in the connection string. This used to work prior to upgrading to v3, it seems something important has changed under the hood…

This is not really v3 related.

It just means you have the wrong connection settings for your target.

So just switch to that target and make sure you enter the right database settings for the server connect database connection for that target and the test of it goes all well.

Hi @George,
this is the successful connection to this target (in my example, the target’s name is synology)

This is what happens, in the same action file where I tested the connection, when I try to edit a custom sql query:

If I use a remote host that accepts a connection string of ‘localhost’, the above works as expected. Previous to upgrading to v3, I could edit this same query on my synology target that requires a 127.0.0.1 connection string. My workaround is to swtich around environments.

Maybe your issue could be related to the bug report I’ve submitted on this?

I think it may be different issues, the switching targets issue I had met pre v3, the one here seems to be around 127.0.0.1 not interpreted as localhost. It’s almost as if you’d need Wappler to tunnel through ssh.

1 Like