Pump and Dashboard unable to connect with MongoDB 4.2.23 Enterprise Atlas cluster (TLS issue?)

Detailed steps to reproduce are mentioned here

I am using GitHub - TykTechnologies/tyk-pro-docker-demo: Tyk Pro demo using docker and docker compose, supercedes tyk_quickstart and locally it works with MongoDB 4.2.23 Community

  tyk-mongo:
    image: mongo:4.2
    container_name: tyk-mongo

    ports:
      - "27017:27017"

    volumes:
      - db-data:/data/db

    networks:
      - tyk

Now I have a MongoDB 4.2.23 Enterprise Atlas cluster created at https://cloud.mongodb.com/
I am unable to make pump and dashboard connect to that mongo cluster (even after setting relevant USESSL and optional SSLINSECURESKIPVERIFY variables as mentioned below.

pump.mongo.env

# Outdated variables in docs that doesn't work https://tyk.io/docs/tyk-pump/tyk-pump-configuration/tyk-pump-environment-variables/
# Docs should be updated
TYK_PMP_PUMPS_MONGO_META_MONGOUSESSL=true
TYK_PMP_PUMPS_MONGO_META_MONGOSSLINSECURESKIPVERIFY=true
TYK_PMP_PUMPS_MONGOAGGREGATE_META_MONGOUSESSL=true
TYK_PMP_PUMPS_MONGOAGGREGATE_META_MONGOSSLINSECURESKIPVERIFY=true
TYK_PMP_PUMPS_MONGOSELECTIVE_META_MONGOUSESSL=true
TYK_PMP_PUMPS_MONGOSELECTIVE_META_MONGOSSLINSECURESKIPVERIFY=true

TYK_PMP_PUMPS_MAIN_TYPE=mongo
TYK_PMP_PUMPS_MAIN_META_COLLECTIONNAME=tyk_analytics
TYK_PMP_PUMPS_MAIN_META_MONGOURL=mongodb+srv://<username>:<password>@something.xyz.mongodb.net/tyk_analytics
# added by me
TYK_PMP_PUMPS_MAIN_META_MONGOUSESSL=true
TYK_PMP_PUMPS_MAIN_META_MONGOSSLINSECURESKIPVERIFY=true

TYK_PMP_PUMPS_MAIN_META_MAXINSERTBATCHSIZEBYTES=80000
TYK_PMP_PUMPS_MAIN_META_MAXDOCUMENTSIZEBYTES=20112

TYK_PMP_PUMPS_MAINAGG_TYPE=mongo-pump-aggregate
TYK_PMP_PUMPS_MAINAGG_META_MONGOURL=mongodb+srv://<username>:<password>@something.xyz.mongodb.net/tyk_analytics
# added by me
TYK_PMP_PUMPS_MAINAGG_META_MONGOUSESSL=true
TYK_PMP_PUMPS_MAINAGG_META_MONGOSSLINSECURESKIPVERIFY=true

TYK_PMP_PUMPS_MAINAGG_META_USEMIXEDCOLLECTION=true
TYK_PMP_PUMPS_MAINAGG_META_TRACKALLPATHS=true

TYK_PMP_UPTIMEPUMPCONFIG_COLLECTIONNAME=tyk_uptime_analytics
TYK_PMP_UPTIMEPUMPCONFIG_MONGOURL=mongodb+srv://<username>:<password>@something.xyz.mongodb.net/tyk_analytics
# added by me
TYK_PMP_UPTIMEPUMPCONFIG_MONGOUSESSL=true
TYK_PMP_UPTIMEPUMPCONFIG_MONGOSSLINSECURESKIPVERIFY=true

TYK_PMP_UPTIMEPUMPCONFIG_MAXINSERTBATCHSIZEBYTES=500000
TYK_PMP_UPTIMEPUMPCONFIG_MAXDOCUMENTSIZEBYTES=200000

dashboard env:

...
TYK_DB_MONGOUSESSL=true

Hi @armujahid,

And thanks for sharing this. Can you try the connection using an old connection string from version 3.4 or earlier?

This stack overflow question will give a hint

1 Like

@Olu Connection string of this form mongodb://<username>:<password>@some-cluster-01-shard-00-00.abcde.mongodb.net:27017,some-cluster-01-shard-00-01.abcde.mongodb.net:27017,some-cluster-01-shard-00-02.abcde.mongodb.net:27017/tyk_analytics?replicaSet=atlas-fghij-shard-0&authSource=admin is working perfectly fine with pump If I set USESSL as

TYK_PMP_PUMPS_MAIN_META_MONGOUSESSL=true
TYK_PMP_PUMPS_MAINAGG_META_MONGOUSESSL=true
TYK_PMP_UPTIMEPUMPCONFIG_MONGOUSESSL=true

Issue is dashboard is still not working probably because TYK_DB_MONGOUSESSL=true as mentioned in docs is outdated/incorrect (like outdated pump variables mentioned above). Any idea how to make dashboard work with that same connection string with TLS?

Currently I am getting this error

time="2022-12-08T08:12:12Z" level=fatal msg="Could not connect to config store" error="no reachable servers"

Dashboard env

TYK_DB_LICENSEKEY=<license>
TYK_DB_STORAGE_MAIN_TYPE=mongo
TYK_DB_STORAGE_MAIN_CONNECTIONSTRING=<same string that works in pump>
TYK_DB_MONGOUSESSL=true # doesn't seem to be working although it's mentioned in docs
TYK_DB_STORAGE_MAIN_MONGOUSESSL=true # also doesn't work
...

I think your environment variables are wrong. The right values are

TYK_DB_MONGOURL
TYK_DB_MONGOSSLINSECURESKIPVERIFY
TYK_DB_MONGOUSESSL

You could also try setting it via the config file

1 Like

Thanks. TYK_DB_MONGOURL is working perfectly fine with TYK_DB_MONGOUSESSL after removing TYK_DB_STORAGE_MAIN_ variables. Dashboard is starting although I couldn’t verify complete functionality since my license has been expired. I will try to renew that. I was following this demo
tyk-pro-docker-demo/docker-compose.yml at master · TykTechnologies/tyk-pro-docker-demo · GitHub that created this confusion.