CouchDB call to wrong IP address when using local container

Wappler Version : Beta 2
Operating System : Win 11
Server Model: node
Database Type: couch
Hosting Type: docker local

Expected behavior

What do you think should happen?

couchDB should bhe called via localhost

Actual behavior

What actually happens?

Strange IP address used for call

I have a local (docker) couchdb created. No production target is defined

image

image

and a connection to it

I have pouch components on the notes page i have been using for some time pointing to it

I view the page in a browser

Initally i thought the issue was the old cors issue

Unitl i notices the IP address of the couch call

i have no idea where the ip address 167.71.25.147 comes from. I can only assume it is cached somewhere from a previous demo container.
I dont even have a container running on that IP, web or database
Could this be a failed update on a JSON file somewhere?

Think I have found the offending file

wapper/targets/Development/files/js/connections/db_connections.js

dmx.databases = dmx.databases || {};
dmx.databases['db_connection'] = {type: "pouchdb", remote: "http://167.71.25.147:9913/my_db"}

but changing to

dmx.databases = dmx.databases || {};
dmx.databases['db_connection'] = { type: "pouchdb", remote: "http://127.0.0.1:9913/my_db" }

and redeploying doesn’t seem to fix it so not sure where to go from here

try http://host.docker.internal:9913/my_db as remote.

changed to

dmx.databases = dmx.databases || {};
dmx.databases['db_connection'] = { type: "pouchdb", remote: "http://host.docker.internal:9913/my_db" }

but still showing wrong IP

pouchdb.min.js:7     GET http://167.71.25.147:9913/my_db/ net::ERR_CONNECTION_TIMED_OUT

Could it also be cached somewhere else?

i created another connection called “temp” which produced this code in temp.js

dmx.databases = dmx.databases || {};
dmx.databases['temp'] = {type: "pouchdb", remote: "http://127.0.0.1:9913/my_db"}

not sure if that helps

I have now switched from “db_connection” to “temp” and the page works correctly so i guess the issue relates to the configuration of db_connection specifically

@Hyperbytes - Hi Brian, not sure of Beta 3 fixed the issue for you. I can’t get it to work. I tried changing the remote to host.docker.internal, but no success.

Working for me, I was using a docker container to host web and mysql, and a second for couch. Had to change host in settings for both containers. I did it manually so don’t know if wappler does it automatically in beta 3

couch settings (separate container)

Web/mysql container

Not sure where the host DB came from but it works, maybe the team have done some sort of mapping on that as everything is working

When you are having a docker project in Wappler when you have both database and web running together on the same server then the docker host names are being used because both the db and web instances are running together on the same internal network - so host names like db just works.

When you are running docker locally and you are using global database for multiple projects then the database service is running on its own private network so it’s only accessible by the special internal docker localhost called host.docker.internal

In the latest beta 3 when you edit the server connect database connection and you have chosen to use a cloud provider (even local one) then the right host name will be chosen when you create new database connection or edit existing one.

So hope this makes sense :slight_smile:

1 Like

Yes, makes total sense tome

sorry @George but this does not seem to be fixed in Beta 3. I updated on Thursday but this is the first chance I have had to continue with current video project

Here is my connection showing host.docker.internal

But if i perform a query, in this case a simple query direct from workflows, it appears to still be looking for 127.0.0.1 rather than the local couch docker containers address.

I now find all my pouch/couch actions are failing in my demo app and strangely in the app no messages are seen in the dev console, not even 500 messages, when using insert/update/delete

I have checked the JSON config files and they appear correct

Are you sure the server connect connection is all saved with the new settings on the right target ? As it seems it is still using the old 127.0.0.1 address

Checked the JSON files and also redeployed to container to be safe

And? What was the connection json file? There is an option in the context menu to “open in code” so it will be opened in the editor

{
  "name": "db_connection",
  "module": "dbconnector",
  "action": "connect",
  "options": {
    "client": "couchdb",
    "connection": {
      "host": "host.docker.internal",
      "port": 9913,
      "user": "myuser",
      "password": "XSDe07x27P8OSu6B",
      "database": "my_db"
    },
    "databaseResource": "Local / couch_db_local",
    "cloudDatabaseName": "my_db"
  },
  "fileName": "db_connection.json"
}
``

Looks good to me is the CouchDB service running? Can you open it in the browser? There it should be with the 127.0.0.1 address or click on the admin dashboard button in the properties

And bizarrely, having come back into office, switched on computer again and started wappler, it has started to work!

image

On a serious note, this sort of reenforces a phenomena i have observed where the settings seem to change randomly and connections seem to “drop out” from time to time.
I will start running in debug mode and try to capture such an event