https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
w

wonderful-xylophone-6904

05/17/2022, 8:57 PM
f

fresh-football-47124

05/17/2022, 9:54 PM
hard to debug - are you able to access the API directly?
w

wonderful-xylophone-6904

05/17/2022, 10:34 PM
Hi Graham, so the API port refuses to connect
I have even ssh'd into the Pod and checked
curl to port 3000 works but port 3100 doesn't
f

fresh-football-47124

05/17/2022, 10:35 PM
can you verify that the api is running?
w

wonderful-xylophone-6904

05/17/2022, 10:35 PM
how do we do that?
My containers are up and running --
f

fresh-football-47124

05/17/2022, 10:44 PM
any logs being outputted?
w

wonderful-xylophone-6904

05/17/2022, 10:50 PM
Pasting container logs from gcp. Pls let me know if any of this means the api server isn't running -
Copy code
2022-05-17T21:44:25.178852034Zyarn run v1.22.19
Info
2022-05-17T21:44:25.233487954Z$ wsrun -p '*-end' -m start
Info
2022-05-17T21:44:25.936212043Zback-end
Info
2022-05-17T21:44:25.936234723Z | $ node dist/server.js
Info
2022-05-17T21:44:25.944241014Zfront-end
Info
2022-05-17T21:44:25.944269352Z | $ next start
Info
2022-05-17T21:44:26.137049861Z | ready - started server on 0.0.0.0:3000, url: <http://localhost:3000>
Error
2022-05-17T21:44:26.187339792Zback-end
Error
2022-05-17T21:44:26.187371460Z | /usr/local/src/app/packages/back-end/dist/util/secrets.js:33
Error
2022-05-17T21:44:26.187452644Z | throw new Error("Cannot use ENCRYPTION_KEY=dev in production. Please set to a long random string.");
Error
2022-05-17T21:44:26.187555492Z | ^
Error
2022-05-17T21:44:26.187645347Z |
Error
2022-05-17T21:44:26.187774125Z | Error: Cannot use ENCRYPTION_KEY=dev in production. Please set to a long random string.
Error
2022-05-17T21:44:26.187876840Z | at Object.<anonymous> (/usr/local/src/app/packages/back-end/dist/util/secrets.js:33:11)
Error
2022-05-17T21:44:26.187967929Z | at Module._compile (internal/modules/cjs/loader.js:1085:14)
Error
2022-05-17T21:44:26.188044761Z | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
Error
2022-05-17T21:44:26.188141754Z | at Module.load (internal/modules/cjs/loader.js:950:32)
Error
2022-05-17T21:44:26.188221076Z | at Function.Module._load (internal/modules/cjs/loader.js:790:12)
Error
2022-05-17T21:44:26.188304447Z | at Module.require (internal/modules/cjs/loader.js:974:19)
f

fresh-football-47124

05/17/2022, 10:50 PM
Copy code
2022-05-17T21:44:26.187452644Z | throw new Error("Cannot use ENCRYPTION_KEY=dev in production. Please set to a long random string.");
^ that's the error
w

wonderful-xylophone-6904

05/17/2022, 10:51 PM
is there a way to disable mongodb encryption?
the helm chart uses bitnami server
f

fresh-football-47124

05/17/2022, 10:52 PM
its encrypting the connection info - you want this
it just has to be a random string
w

wonderful-xylophone-6904

05/17/2022, 10:52 PM
ok let me do that
ok the logs are now showing this but i still get connection refused on port 3100 -
Copy code
Info
2022-05-17T22:57:29.814808616Z{attr: {…}, c: NETWORK, ctx: listener, id: 22943, msg: Connection accepted, s: I, t: {…}}
Info
2022-05-17T22:57:29.815198909Z{attr: {…}, c: NETWORK, ctx: conn1550, id: 51800, msg: client metadata, s: I, t: {…}}
Info
2022-05-17T22:57:29.819345215Z{attr: {…}, c: NETWORK, ctx: conn1549, id: 22944, msg: Connection ended, s: I, t: {…}}
Info
2022-05-17T22:57:29.819770907Z{attr: {…}, c: NETWORK, ctx: conn1550, id: 22944, msg: Connection ended, s: I, t: {…}}
Info
2022-05-17T22:57:39.780664998Z{attr: {…}, c: NETWORK, ctx: listener, id: 22943, msg: Connection accepted, s: I, t: {…}}
Info
2022-05-17T22:57:39.780986072Z{attr: {…}, c: NETWORK, ctx: conn1551, id: 51800, msg: client metadata, s: I, t: {…}}
Info
2022-05-17T22:57:39.785589625Z{attr: {…}, c: NETWORK, ctx: conn1551, id: 22944, msg: Connection ended, s: I, t: {…}}
Info
2022-05-17T22:57:39.832112370Z{attr: {…}, c: NETWORK, ctx: listener, id: 22943, msg: Connection accepted, s: I, t: {…}}
Info
2022-05-17T22:57:39.832271998Z{attr: {…}, c: NETWORK, ctx: conn1552, id: 51800, msg: client metadata, s: I, t: {…}}
Info
2022-05-17T22:57:39.836874939Z{attr: {…}, c: NETWORK, ctx: conn1552, id: 22944, msg: Connection ended, s: I, t: {…}}
f

fresh-football-47124

05/17/2022, 10:59 PM
can you past the full logs?
w

wonderful-xylophone-6904

05/17/2022, 10:59 PM
oops sorry i pasted the mongodb container logs
let me destroy all the pods and recreate them and paste fresh log
so I've set both the encryption key and jwt secret in the growthbook deployment env variables in the config now -- yet it's complaining that it's not set
Copy code
containers:
        - name: growthbook
          securityContext:
            null
          image: "growthbook/growthbook:latest"
          imagePullPolicy: Always
          env:
          - name: NODE_ENV
            value: production
          - name: MONGODB_URI
            value: "<mongodb://root:password@mongo:27017/>"
#            valueFrom:
#              secretKeyRef:
#                key: mongo-connection-uri
#                name: growthbook-external-secret
          - name: JWT_SECRET
            value: "abcd@123"
#            valueFrom:
#              secretKeyRef:
#                key: jwt-secret
#                name: growthbook-external-secret
          - name: ENCRYPTION_KEY
            value: "abcd@123"
Here are the logs --
Copy code
Info
2022-05-17T20:45:24.140599892Zyarn run v1.22.19
Info
2022-05-17T20:45:24.214144125Z$ wsrun -p '*-end' -m start
Info
2022-05-17T20:45:25.103020191Zback-end
Info
2022-05-17T20:45:25.103061151Z | $ node dist/server.js
Info
2022-05-17T20:45:25.118528355Zfront-end
Info
2022-05-17T20:45:25.118569706Z | $ next start
Info
2022-05-17T20:45:25.318893584Z | ready - started server on 0.0.0.0:3000, url: <http://localhost:3000>
Error
2022-05-17T20:45:25.369041935Zback-end
Error
2022-05-17T20:45:25.369070005Z | /usr/local/src/app/packages/back-end/dist/util/secrets.js:33
Error
2022-05-17T20:45:25.369242902Z | throw new Error("Cannot use ENCRYPTION_KEY=dev in production. Please set to a long random string.");
Error
2022-05-17T20:45:25.369299183Z | ^
Error
2022-05-17T20:45:25.369304549Z |
Error
2022-05-17T20:45:25.369394067Z | Error: Cannot use ENCRYPTION_KEY=dev in production. Please set to a long random string.
Error
2022-05-17T20:45:25.369565164Z | at Object.<anonymous> (/usr/local/src/app/packages/back-end/dist/util/secrets.js:33:11)
Error
2022-05-17T20:45:25.369769506Z | at Module._compile (internal/modules/cjs/loader.js:1085:14)
Error
2022-05-17T20:45:25.370232375Z | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
Error
2022-05-17T20:45:25.370497841Z | at Module.load (internal/modules/cjs/loader.js:950:32)
Error
2022-05-17T20:45:25.370678141Z | at Function.Module._load (internal/modules/cjs/loader.js:790:12)
I just checked the container and my environment variables are properly set in the growthbook container as is specified in the k8s deployment config
but when I ran
yarn start
I got the following error -
Copy code
| Error: MongoDB connection error.
 |     at /usr/local/src/app/packages/back-end/dist/init/mongo.js:34:15
 |     at Generator.throw (<anonymous>)
 |     at rejected (/usr/local/src/app/packages/back-end/dist/init/mongo.js:6:65)
Copy code
yarn start
yarn run v1.22.19
$ wsrun -p '*-end' -m start
back-end
$ node dist/server.js
front-end
$ next start
 | Error: listen EADDRINUSE: address already in use 0.0.0.0:3000
 |     at Server.setupListenHandle [as _listen2] (net.js:1331:16)
 |     at listenInCluster (net.js:1379:12)
 |     at doListen (net.js:1516:7)
 |     at processTicksAndRejections (internal/process/task_queues.js:83:21) {
 |   code: 'EADDRINUSE',
 |   errno: -98,
 |   syscall: 'listen',
 |   address: '0.0.0.0',
 |   port: 3000
 | }
error Command failed with exit code 1.
info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.
 | `yarn start` failed with exit code 1
back-end
 |   Back-end is running at <http://localhost:3100> in production mode
 |   Press CTRL-C to stop
 | 


 | MongooseServerSelectionError: getaddrinfo ENOTFOUND mongo
 |     at NativeConnection.Connection.openUri (/usr/local/src/app/node_modules/mongoose/lib/connection.js:847:32)
 |     at /usr/local/src/app/node_modules/mongoose/lib/index.js:351:10
 |     at /usr/local/src/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5
 |     at Promise._execute (/usr/local/src/app/node_modules/bluebird/js/release/debuggability.js:384:9)
 |     at Promise._resolveFromExecutor (/usr/local/src/app/node_modules/bluebird/js/release/promise.js:518:18)
 |     at new Promise (/usr/local/src/app/node_modules/bluebird/js/release/promise.js:103:10)
 |     at promiseOrCallback (/usr/local/src/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
 |     at Mongoose._promiseOrCallback (/usr/local/src/app/node_modules/mongoose/lib/index.js:1149:10)
 |     at Mongoose.connect (/usr/local/src/app/node_modules/mongoose/lib/index.js:350:20)
 |     at /usr/local/src/app/packages/back-end/dist/init/mongo.js:26:41
 |     at Generator.next (<anonymous>)
 |     at /usr/local/src/app/packages/back-end/dist/init/mongo.js:8:71
 |     at new Promise (<anonymous>)
 |     at __awaiter (/usr/local/src/app/packages/back-end/dist/init/mongo.js:4:12)
 |     at Object.exports.default (/usr/local/src/app/packages/back-end/dist/init/mongo.js:19:25)
 |     at /usr/local/src/app/packages/back-end/dist/app.js:98:38
 |     at Generator.next (<anonymous>)
 |     at /usr/local/src/app/packages/back-end/dist/app.js:27:71
 |     at new Promise (<anonymous>)
 |     at __awaiter (/usr/local/src/app/packages/back-end/dist/app.js:23:12)
 |     at /usr/local/src/app/packages/back-end/dist/app.js:97:34
 |     at /usr/local/src/app/packages/back-end/dist/app.js:100:16 {
 |   reason: TopologyDescription {
 |     type: 'Single',
 |     setName: null,
 |     maxSetVersion: null,
 |     maxElectionId: null,
 |     servers: Map(1) { 'mongo:27017' => [ServerDescription] },
 |     stale: false,
 |     compatible: true,
 |     compatibilityError: null,
 |     logicalSessionTimeoutMinutes: null,
 |     heartbeatFrequencyMS: 10000,
 |     localThresholdMS: 15,
 |     commonWireVersion: null
 |   }
 | }
 | Error: MongoDB connection error.
 |     at /usr/local/src/app/packages/back-end/dist/init/mongo.js:34:15
 |     at Generator.throw (<anonymous>)
 |     at rejected (/usr/local/src/app/packages/back-end/dist/init/mongo.js:6:65)
error Command failed with exit code 1.
info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.
 | `yarn start` failed with exit code 1
error Command failed with exit code 1.
info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.
f

fresh-football-47124

05/17/2022, 11:20 PM
are you wanting to use the docker container or the yarn method?
w

wonderful-xylophone-6904

05/17/2022, 11:21 PM
no i want to use the docker container
i was just trying to replicate what I saw in the logs to see if I get same error
in the container logs I keep getting --
Copy code
2022-05-17T23:04:26.794226166Z | `yarn start` failed with exit code 1
f

fresh-football-47124

05/17/2022, 11:23 PM
we have this in our code:
Copy code
export const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY || "dev";
if (prod && ENCRYPTION_KEY === "dev") {
  throw new Error(
    "Cannot use ENCRYPTION_KEY=dev in production. Please set to a long random string."
  );
}
so it seems the environment variable is not getting to the container
w

wonderful-xylophone-6904

05/17/2022, 11:24 PM
I'm in the container and I see that it is set
Copy code
KUBERNETES_SERVICE_PORT_HTTPS=443
KUBERNETES_SERVICE_PORT=443
AB_TEST_APP_MONGODB_SERVICE_HOST=10.30.89.227
HOSTNAME=ab-test-app-growthbook-65764f8b76-k6zg6
PYTHON_VERSION=3.9.12
ENCRYPTION_KEY=abcd@123
AB_TEST_APP_MONGODB_METRICS_PORT_9216_TCP=<tcp://10.30.225.244:9216>
AB_TEST_APP_GROWTHBOOK_SERVICE_PORT_FRONTEND_PORT=3000
APP_ORIGIN=<http://localhost:3000>
AB_TEST_APP_MONGODB_SERVICE_PORT_MONGODB=27017
AB_TEST_APP_GROWTHBOOK_PORT_3000_TCP_PROTO=tcp
AB_TEST_APP_MONGODB_METRICS_PORT_9216_TCP_PORT=9216
AB_TEST_APP_GROWTHBOOK_PORT_3100_TCP_ADDR=10.30.37.75
PWD=/usr/local/src/app
AB_TEST_APP_MONGODB_PORT_27017_TCP_PORT=27017
AB_TEST_APP_MONGODB_SERVICE_PORT=27017
PYTHON_SETUPTOOLS_VERSION=58.1.0
NODE_ENV=production
MONGODB_URI=<mongodb://root:password@mongo:27017/>
AB_TEST_APP_MONGODB_METRICS_PORT=<tcp://10.30.225.244:9216>
HOME=/root
LANG=C.UTF-8
KUBERNETES_PORT_443_TCP=<tcp://10.30.0.1:443>
AB_TEST_APP_GROWTHBOOK_PORT_3100_TCP_PROTO=tcp
AB_TEST_APP_MONGODB_PORT_27017_TCP_PROTO=tcp
AB_TEST_APP_MONGODB_PORT_27017_TCP_ADDR=10.30.89.227
AB_TEST_APP_GROWTHBOOK_PORT_3000_TCP_PORT=3000
AB_TEST_APP_MONGODB_METRICS_SERVICE_PORT_HTTP_METRICS=9216
AB_TEST_APP_GROWTHBOOK_SERVICE_PORT_BACKEND_PORT=3100
TERM=xterm
AB_TEST_APP_GROWTHBOOK_PORT_3100_TCP_PORT=3100
AB_TEST_APP_GROWTHBOOK_PORT_3000_TCP=<tcp://10.30.37.75:3000>
AB_TEST_APP_GROWTHBOOK_SERVICE_PORT=3000
AB_TEST_APP_GROWTHBOOK_SERVICE_HOST=10.30.37.75
SHLVL=1
AB_TEST_APP_MONGODB_METRICS_SERVICE_HOST=10.30.225.244
AB_TEST_APP_GROWTHBOOK_PORT_3000_TCP_ADDR=10.30.37.75
KUBERNETES_PORT_443_TCP_PROTO=tcp
AB_TEST_APP_GROWTHBOOK_PORT_3100_TCP=<tcp://10.30.37.75:3100>
AB_TEST_APP_MONGODB_METRICS_SERVICE_PORT=9216
PYTHON_PIP_VERSION=22.0.4
KUBERNETES_PORT_443_TCP_ADDR=10.30.0.1
PYTHON_GET_PIP_SHA256=e235c437e5c7d7524fbce3880ca39b917a73dc565e0c813465b7a7a329bb279a
AB_TEST_APP_MONGODB_METRICS_PORT_9216_TCP_PROTO=tcp
KUBERNETES_SERVICE_HOST=10.30.0.1
KUBERNETES_PORT=<tcp://10.30.0.1:443>
KUBERNETES_PORT_443_TCP_PORT=443
AB_TEST_APP_MONGODB_PORT_27017_TCP=<tcp://10.30.89.227:27017>
PYTHON_GET_PIP_URL=<https://github.com/pypa/get-pip/raw/38e54e5de07c66e875c11a1ebbdb938854625dd8/public/get-pip.py>
AB_TEST_APP_MONGODB_METRICS_PORT_9216_TCP_ADDR=10.30.225.244
AB_TEST_APP_GROWTHBOOK_PORT=<tcp://10.30.37.75:3000>
PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
API_HOST=<http://localhost:3100>
JWT_SECRET=abcd@123
AB_TEST_APP_MONGODB_PORT=<tcp://10.30.89.227:27017>
f

fresh-football-47124

05/17/2022, 11:28 PM
its unclear if that is making it to growthbook - either it needs to be restarted or there is something else going on - you could test it out by changing somehting like the APP_ORIGIN env and see if you can access GrowthBook on that new url/port
w

wonderful-xylophone-6904

05/17/2022, 11:30 PM
yes when I change the APP_ORIGIN to say from http://localhost to http://host.docker.internal the error changes for e.g. from --
to this -
so the APP_ORIGIN env variable is being picked up
On my desktop container I'm using the docker compose file from your repo which doesn't contain either the JWT or ECRYPTION secret set in the environment
I also checked the environment variables within the container on my laptop and it isn't set
so why doesn't it throw a fit?
f

fresh-football-47124

05/17/2022, 11:40 PM
probably not set for production
w

wonderful-xylophone-6904

05/17/2022, 11:41 PM
actually I have set NODE_ENV="production"
but guessing that env is ignored
not sure why
here's the env output from my laptop -
Copy code
HOSTNAME=d25eab8fd525
PYTHON_VERSION=3.9.12
APP_ORIGIN=<http://localhost:3000>
PWD=/usr/local/src/app
PYTHON_SETUPTOOLS_VERSION=58.1.0
NODE_ENV="production"
MONGODB_URI=<mongodb://root:password@mongo:27017/>
HOME=/root
LANG=C.UTF-8
TERM=xterm
SHLVL=1
PYTHON_PIP_VERSION=22.0.4
PYTHON_GET_PIP_SHA256=e235c437e5c7d7524fbce3880ca39b917a73dc565e0c813465b7a7a329bb279a
PYTHON_GET_PIP_URL=<https://github.com/pypa/get-pip/raw/38e54e5de07c66e875c11a1ebbdb938854625dd8/public/get-pip.py>
PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
API_HOST=<http://localhost:3100>
_=/usr/bin/env
f

fresh-football-47124

05/17/2022, 11:43 PM
thats container?
w

wonderful-xylophone-6904

05/17/2022, 11:43 PM
yes
Copy code
CONTAINER ID   IMAGE                          COMMAND                  CREATED        STATUS       PORTS                                            NAMES
d25eab8fd525   growthbook/growthbook:latest   "yarn start"             30 hours ago   Up 7 hours   0.0.0.0:3000->3000/tcp, 0.0.0.0:3100->3100/tcp   growthbook-growthbook-1
ea8110e530a8   mongo:latest                   "docker-entrypoint.s…"   30 hours ago   Up 7 hours   27017/tcp                                        growthbook-mongo-1
it works perfectly well
doesn't get set in k8s pods
but works in docker containers
and possibly the following lines are also using the || value export const APP_ORIGIN = process.env.APP_ORIGIN || "http://localhost:3000"
still doesn't make sense why process.env.NODE_ENV should be set but not others
f

fresh-football-47124

05/17/2022, 11:53 PM
that's right
should be working, but hard to debug from here
w

wonderful-xylophone-6904

05/17/2022, 11:59 PM
I'm pasting all the environment variables from node process
Copy code
node
Welcome to Node.js v14.19.2.
Type ".help" for more information.
> process.env
> process.env
> process.env
{
  KUBERNETES_SERVICE_PORT_HTTPS: '443',
  KUBERNETES_SERVICE_PORT: '443',
  AB_TEST_APP_MONGODB_SERVICE_HOST: '10.30.89.227',
  HOSTNAME: 'ab-test-app-growthbook-6dd5f557d8-8wpbw',
  PYTHON_VERSION: '3.9.12',
  ENCRYPTION_KEY: 'abcd@123',
  AB_TEST_APP_MONGODB_METRICS_PORT_9216_TCP: '<tcp://10.30.225.244:9216>',
  AB_TEST_APP_GROWTHBOOK_SERVICE_PORT_FRONTEND_PORT: '3000',
  APP_ORIGIN: '<http://host.docker.internal:3000>',
  AB_TEST_APP_MONGODB_SERVICE_PORT_MONGODB: '27017',
  AB_TEST_APP_GROWTHBOOK_PORT_3000_TCP_PROTO: 'tcp',
  AB_TEST_APP_MONGODB_METRICS_PORT_9216_TCP_PORT: '9216',
  AB_TEST_APP_GROWTHBOOK_PORT_3100_TCP_ADDR: '10.30.37.75',
  PWD: '/usr/local/src/app',
  AB_TEST_APP_MONGODB_PORT_27017_TCP_PORT: '27017',
  AB_TEST_APP_MONGODB_SERVICE_PORT: '27017',
  PYTHON_SETUPTOOLS_VERSION: '58.1.0',
  NODE_ENV: 'production',
  MONGODB_URI: '<mongodb://root:password@mongo:27017/>',
  AB_TEST_APP_MONGODB_METRICS_PORT: '<tcp://10.30.225.244:9216>',
  HOME: '/root',
  LANG: 'C.UTF-8',
  KUBERNETES_PORT_443_TCP: '<tcp://10.30.0.1:443>',
  AB_TEST_APP_GROWTHBOOK_PORT_3100_TCP_PROTO: 'tcp',
  AB_TEST_APP_MONGODB_PORT_27017_TCP_PROTO: 'tcp',
  AB_TEST_APP_MONGODB_PORT_27017_TCP_ADDR: '10.30.89.227',
  AB_TEST_APP_GROWTHBOOK_PORT_3000_TCP_PORT: '3000',
  AB_TEST_APP_MONGODB_METRICS_SERVICE_PORT_HTTP_METRICS: '9216',
  AB_TEST_APP_GROWTHBOOK_SERVICE_PORT_BACKEND_PORT: '3100',
  TERM: 'xterm',
  AB_TEST_APP_GROWTHBOOK_PORT_3100_TCP_PORT: '3100',
  AB_TEST_APP_GROWTHBOOK_PORT_3000_TCP: '<tcp://10.30.37.75:3000>',
  AB_TEST_APP_GROWTHBOOK_SERVICE_PORT: '3000',
  AB_TEST_APP_GROWTHBOOK_SERVICE_HOST: '10.30.37.75',
  SHLVL: '1',
  AB_TEST_APP_MONGODB_METRICS_SERVICE_HOST: '10.30.225.244',
  AB_TEST_APP_GROWTHBOOK_PORT_3000_TCP_ADDR: '10.30.37.75',
  KUBERNETES_PORT_443_TCP_PROTO: 'tcp',
  AB_TEST_APP_GROWTHBOOK_PORT_3100_TCP: '<tcp://10.30.37.75:3100>',
  AB_TEST_APP_MONGODB_METRICS_SERVICE_PORT: '9216',
  PYTHON_PIP_VERSION: '22.0.4',
  KUBERNETES_PORT_443_TCP_ADDR: '10.30.0.1',
  PYTHON_GET_PIP_SHA256: 'e235c437e5c7d7524fbce3880ca39b917a73dc565e0c813465b7a7a329bb279a',
  AB_TEST_APP_MONGODB_METRICS_PORT_9216_TCP_PROTO: 'tcp',
  KUBERNETES_SERVICE_HOST: '10.30.0.1',
  KUBERNETES_PORT: '<tcp://10.30.0.1:443>',
  KUBERNETES_PORT_443_TCP_PORT: '443',
  AB_TEST_APP_MONGODB_PORT_27017_TCP: '<tcp://10.30.89.227:27017>',
  PYTHON_GET_PIP_URL: '<https://github.com/pypa/get-pip/raw/38e54e5de07c66e875c11a1ebbdb938854625dd8/public/get-pip.py>',
  AB_TEST_APP_MONGODB_METRICS_PORT_9216_TCP_ADDR: '10.30.225.244',
  AB_TEST_APP_GROWTHBOOK_PORT: '<tcp://10.30.37.75:3000>',
  PATH: '/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
  API_HOST: '<http://host.docker.internal:3100>',
  JWT_SECRET: 'abcd@123',
  AB_TEST_APP_MONGODB_PORT: '<tcp://10.30.89.227:27017>',
  _: '/usr/bin/node'
}
I think I found the fix
Copy code
node
Welcome to Node.js v14.19.2.
Type ".help" for more information.
> ENVIRONMENT = process.env.NODE_ENV;
'production'
> prod = ENVIRONMENT === "production";
true
> JWT_SECRET = process.env.JWT_SECRET || "dev";
'abcd@123'
> if (prod && !IS_CLOUD && JWT_SECRET === "dev") {
...   throw new Error(
.....     "Cannot use JWT_SECRET=dev in production. Please set to a long random string."
.....   );
... }
Uncaught ReferenceError: IS_CLOUD is not defined
> IS_CLOUD = !!process.env.IS_CLOUD;
false
> if (prod && !IS_CLOUD && JWT_SECRET === "dev") {
...   throw new Error(
.....     "Cannot use JWT_SECRET=dev in production. Please set to a long random string."
.....   );
... }
undefined
>
I think we need to define IS_CLOUD
that didn't help so I changed the nod env to dev
but I get mongodb connection error now -
Copy code
22-05-17T23:32:11.899670570Z | MongooseServerSelectionError: getaddrinfo ENOTFOUND mongo
Error
2022-05-17T23:32:11.900118278Z | at NativeConnection.Connection.openUri (/usr/local/src/app/node_modules/mongoose/lib/connection.js:847:32)
Error
2022-05-17T23:32:11.900155182Z | at /usr/local/src/app/node_modules/mongoose/lib/index.js:351:10
Error
2022-05-17T23:32:11.900247592Z | at /usr/local/src/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5
Error
2022-05-17T23:32:11.900620444Z | at Promise._execute (/usr/local/src/app/node_modules/bluebird/js/release/debuggability.js:384:9)
Error
2022-05-17T23:32:11.900645480Z | at Promise._resolveFromExecutor (/usr/local/src/app/node_modules/bluebird/js/release/promise.js:518:18)
Error
2022-05-17T23:32:11.900713247Z | at new Promise (/usr/local/src/app/node_modules/bluebird/js/release/promise.js:103:10)
Error
2022-05-17T23:32:11.900721674Z | at promiseOrCallback (/usr/local/src/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
Error
2022-05-17T23:32:11.901071839Z | at Mongoose._promiseOrCallback (/usr/local/src/app/node_modules/mongoose/lib/index.js:1149:10)
Error
2022-05-17T23:32:11.901103987Z | at Mongoose.connect (/usr/local/src/app/node_modules/mongoose/lib/index.js:350:20)
Error
2022-05-17T23:32:11.901111499Z | at /usr/local/src/app/packages/back-end/dist/init/mongo.js:26:41
Error
2022-05-17T23:32:11.901125621Z | at Generator.next (<anonymous>)
f

fresh-football-47124

05/18/2022, 12:48 AM
is that mongo again?
w

wonderful-xylophone-6904

05/18/2022, 12:52 AM
OK fixed mongo
in the deployment manifest it had to be thus --
Copy code
- name: MONGODB_URI
#            value: "<mongodb://root:password@mongo:27017/>"
            value: "<mongodb://root:password@ab-test-app-mongodb:27017/>"
the name of the service that lets you connect to mongo from one pod to another
Copy code
ab-test-app-mongodb
so I'm able to connect to port 3100 now 🎉
however, when I connect to port 3000 I get --
Copy code
Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist.
9919-99cd3bd3a8033b6fe5ea.js:1 Error: 
      auth0-spa-js must run on a secure origin. See <https://github.com/auth0/auth0-spa-js/blob/master/FAQ.md#why-do-i-get-auth0-spa-js-must-run-on-a-secure-origin> for more information.
    
    at 5179-6f12d4801169f2637ba9.js:1:68600
    at new e (5179-6f12d4801169f2637ba9.js:1:68806)
    at 5179-6f12d4801169f2637ba9.js:1:86227
    at 5179-6f12d4801169f2637ba9.js:1:2350
    at Object.next (5179-6f12d4801169f2637ba9.js:1:2455)
    at 5179-6f12d4801169f2637ba9.js:1:1392
    at new Promise (<anonymous>)
    at u (5179-6f12d4801169f2637ba9.js:1:1137)
    at t.ZP (5179-6f12d4801169f2637ba9.js:1:86126)
    at 9919-99cd3bd3a8033b6fe5ea.js:1:17222
(anonymous) @ 9919-99cd3bd3a8033b6fe5ea.js:1
Promise.catch (async)
(anonymous) @ 9919-99cd3bd3a8033b6fe5ea.js:1
Ii @ framework-eca9c7ed50c006ceb492.js:1
t.unstable_runWithPriority @ framework-eca9c7ed50c006ceb492.js:1
Wl @ framework-eca9c7ed50c006ceb492.js:1
Oi @ framework-eca9c7ed50c006ceb492.js:1
(anonymous) @ framework-eca9c7ed50c006ceb492.js:1
D @ framework-eca9c7ed50c006ceb492.js:1
w.port1.onmessage @ framework-eca9c7ed50c006ceb492.js:1
35.233.230.197/:1 Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist.
container logs are clean
above error is in the browser dev console
f

fresh-football-47124

05/18/2022, 12:55 AM
how are you planning on running this, is it for your use?
w

wonderful-xylophone-6904

05/18/2022, 12:55 AM
f

fresh-football-47124

05/18/2022, 12:55 AM
can you paste the env again?
w

wonderful-xylophone-6904

05/18/2022, 12:55 AM
sure --
Copy code
KUBERNETES_SERVICE_PORT_HTTPS=443
KUBERNETES_SERVICE_PORT=443
AB_TEST_APP_MONGODB_SERVICE_HOST=10.30.89.227
HOSTNAME=ab-test-app-growthbook-684bc9b974-9bfwr
PYTHON_VERSION=3.9.12
ENCRYPTION_KEY=abcd@123
AB_TEST_APP_MONGODB_METRICS_PORT_9216_TCP=<tcp://10.30.225.244:9216>
AB_TEST_APP_GROWTHBOOK_SERVICE_PORT_FRONTEND_PORT=3000
APP_ORIGIN=<http://localhost:3000>
AB_TEST_APP_MONGODB_SERVICE_PORT_MONGODB=27017
AB_TEST_APP_GROWTHBOOK_PORT_3000_TCP_PROTO=tcp
AB_TEST_APP_MONGODB_METRICS_PORT_9216_TCP_PORT=9216
AB_TEST_APP_GROWTHBOOK_PORT_3100_TCP_ADDR=10.30.37.75
PWD=/usr/local/src/app
AB_TEST_APP_MONGODB_PORT_27017_TCP_PORT=27017
AB_TEST_APP_MONGODB_SERVICE_PORT=27017
PYTHON_SETUPTOOLS_VERSION=58.1.0
NODE_ENV=dev
MONGODB_URI=<mongodb://root:password@ab-test-app-mongodb:27017/>
AB_TEST_APP_MONGODB_METRICS_PORT=<tcp://10.30.225.244:9216>
HOME=/root
LANG=C.UTF-8
KUBERNETES_PORT_443_TCP=<tcp://10.30.0.1:443>
AB_TEST_APP_GROWTHBOOK_PORT_3100_TCP_PROTO=tcp
AB_TEST_APP_MONGODB_PORT_27017_TCP_PROTO=tcp
AB_TEST_APP_MONGODB_PORT_27017_TCP_ADDR=10.30.89.227
IS_CLOUD=true
AB_TEST_APP_GROWTHBOOK_PORT_3000_TCP_PORT=3000
AB_TEST_APP_MONGODB_METRICS_SERVICE_PORT_HTTP_METRICS=9216
AB_TEST_APP_GROWTHBOOK_SERVICE_PORT_BACKEND_PORT=3100
TERM=xterm
AB_TEST_APP_GROWTHBOOK_PORT_3100_TCP_PORT=3100
AB_TEST_APP_GROWTHBOOK_PORT_3000_TCP=<tcp://10.30.37.75:3000>
AB_TEST_APP_GROWTHBOOK_SERVICE_PORT=3000
AB_TEST_APP_GROWTHBOOK_SERVICE_HOST=10.30.37.75
SHLVL=1
AB_TEST_APP_MONGODB_METRICS_SERVICE_HOST=10.30.225.244
AB_TEST_APP_GROWTHBOOK_PORT_3000_TCP_ADDR=10.30.37.75
KUBERNETES_PORT_443_TCP_PROTO=tcp
AB_TEST_APP_GROWTHBOOK_PORT_3100_TCP=<tcp://10.30.37.75:3100>
AB_TEST_APP_MONGODB_METRICS_SERVICE_PORT=9216
PYTHON_PIP_VERSION=22.0.4
KUBERNETES_PORT_443_TCP_ADDR=10.30.0.1
PYTHON_GET_PIP_SHA256=e235c437e5c7d7524fbce3880ca39b917a73dc565e0c813465b7a7a329bb279a
AB_TEST_APP_MONGODB_METRICS_PORT_9216_TCP_PROTO=tcp
KUBERNETES_SERVICE_HOST=10.30.0.1
KUBERNETES_PORT=<tcp://10.30.0.1:443>
KUBERNETES_PORT_443_TCP_PORT=443
AB_TEST_APP_MONGODB_PORT_27017_TCP=<tcp://10.30.89.227:27017>
PYTHON_GET_PIP_URL=<https://github.com/pypa/get-pip/raw/38e54e5de07c66e875c11a1ebbdb938854625dd8/public/get-pip.py>
AB_TEST_APP_MONGODB_METRICS_PORT_9216_TCP_ADDR=10.30.225.244
AB_TEST_APP_GROWTHBOOK_PORT=<tcp://10.30.37.75:3000>
PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
API_HOST=<http://localhost:3100>
JWT_SECRET=abcd@123
AB_TEST_APP_MONGODB_PORT=<tcp://10.30.89.227:27017>
_=/usr/bin/env
https://growthbookusers.slack.com/archives/C01T6Q1SVFV/p1652835310815129?thread_ts=1652821023.479679&amp;cid=C01T6Q1SVFV This is a sandbox environment. I'm want to run experiments on a sandbox CMS drupal site
f

fresh-football-47124

05/18/2022, 12:58 AM
that Auth0 error is probably from having is_cloud to true
w

wonderful-xylophone-6904

05/18/2022, 12:58 AM
ok let me turn that off
you were right
that browser error went away but I'm back to square one where this all started with my own service and pod config --
I change from http://host.docker.internal:3100 to http://localhost:3100 and I still have this issue
when I curl inside the container http://host.docker.internal:3100/ doesn't work but http://localhost:3100/ does
and so does http://ab-test-app-growthbook:3100 which is defined as a service connecting to the gb container in the k8s config
Again switched to localhost:3100 but same issue
this is the console error -
Copy code
Access to fetch at '<http://localhost:3100/auth/refresh>' from origin '<http://35.233.230.197:3000>' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space `local`.
Copy code
Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist.
35.233.230.197/:1 Access to fetch at '<http://localhost:3100/auth/refresh>' from origin '<http://35.233.230.197:3000>' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space `local`.
9919-99cd3bd3a8033b6fe5ea.js:1          POST <http://localhost:3100/auth/refresh> net::ERR_FAILED
(anonymous) @ 9919-99cd3bd3a8033b6fe5ea.js:1
l @ commons-daae3e01897c05f6d8fb.js:1
(anonymous) @ commons-daae3e01897c05f6d8fb.js:1
(anonymous) @ commons-daae3e01897c05f6d8fb.js:1
r @ 4236-9bfcea74f5837cad91f0.js:1
a @ 4236-9bfcea74f5837cad91f0.js:1
(anonymous) @ 4236-9bfcea74f5837cad91f0.js:1
(anonymous) @ 4236-9bfcea74f5837cad91f0.js:1
S @ 9919-99cd3bd3a8033b6fe5ea.js:1
N @ 9919-99cd3bd3a8033b6fe5ea.js:1
(anonymous) @ 9919-99cd3bd3a8033b6fe5ea.js:1
l @ commons-daae3e01897c05f6d8fb.js:1
(anonymous) @ commons-daae3e01897c05f6d8fb.js:1
(anonymous) @ commons-daae3e01897c05f6d8fb.js:1
r @ 4236-9bfcea74f5837cad91f0.js:1
a @ 4236-9bfcea74f5837cad91f0.js:1
(anonymous) @ 4236-9bfcea74f5837cad91f0.js:1
(anonymous) @ 4236-9bfcea74f5837cad91f0.js:1
(anonymous) @ 9919-99cd3bd3a8033b6fe5ea.js:1
(anonymous) @ 9919-99cd3bd3a8033b6fe5ea.js:1
Ii @ framework-eca9c7ed50c006ceb492.js:1
t.unstable_runWithPriority @ framework-eca9c7ed50c006ceb492.js:1
Wl @ framework-eca9c7ed50c006ceb492.js:1
Oi @ framework-eca9c7ed50c006ceb492.js:1
(anonymous) @ framework-eca9c7ed50c006ceb492.js:1
D @ framework-eca9c7ed50c006ceb492.js:1
w.port1.onmessage @ framework-eca9c7ed50c006ceb492.js:1
9919-99cd3bd3a8033b6fe5ea.js:1 TypeError: Failed to fetch
    at 9919-99cd3bd3a8033b6fe5ea.js:1:24856
    at l (commons-daae3e01897c05f6d8fb.js:1:35273)
    at Generator._invoke (commons-daae3e01897c05f6d8fb.js:1:35061)
    at Generator.next (commons-daae3e01897c05f6d8fb.js:1:35698)
    at r (4236-9bfcea74f5837cad91f0.js:1:71428)
    at a (4236-9bfcea74f5837cad91f0.js:1:71631)
    at 4236-9bfcea74f5837cad91f0.js:1:71690
    at new Promise (<anonymous>)
    at 4236-9bfcea74f5837cad91f0.js:1:71571
    at S (9919-99cd3bd3a8033b6fe5ea.js:1:25516)
(anonymous) @ 9919-99cd3bd3a8033b6fe5ea.js:1
Promise.catch (async)
(anonymous) @ 9919-99cd3bd3a8033b6fe5ea.js:1
Ii @ framework-eca9c7ed50c006ceb492.js:1
t.unstable_runWithPriority @ framework-eca9c7ed50c006ceb492.js:1
Wl @ framework-eca9c7ed50c006ceb492.js:1
Oi @ framework-eca9c7ed50c006ceb492.js:1
(anonymous) @ framework-eca9c7ed50c006ceb492.js:1
D @ framework-eca9c7ed50c006ceb492.js:1
w.port1.onmessage @ framework-eca9c7ed50c006ceb492.js:1
35.233.230.197/:1 Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist.
f

fresh-football-47124

05/18/2022, 1:08 AM
what url are you hitting the main app from? is it
Copy code
<http://35.233.230.197:3000>
?
w

wonderful-xylophone-6904

05/18/2022, 1:10 AM
yes
I see that the client is making calls to -- localhost instead of to the server IP
which is why the CORS error
f

fresh-football-47124

05/18/2022, 1:11 AM
that url should match APP_ORIGIN
w

wonderful-xylophone-6904

05/18/2022, 1:14 AM
I've changed the config to point to the ephemeral external IP -
Copy code
- name: APP_ORIGIN
#            value: <https://my-app-origin.io:443>
#            value: <http://host.docker.internal:3000>
#            value: <http://localhost:3000>
            value: <http://35.233.230.197/:3000>
          - name: API_HOST
#            value: <https://my-api-host.io:443>
#            value: <http://host.docker.internal:3100>
#            value: <http://localhost:3100>
#            value: <http://ab-test-app-growthbook:3100>
            value: <http://35.233.230.197/:3100>
Copy code
// 20220517181312
// <http://35.233.230.197:3100/>

{
  "name": "GrowthBook API",
  "production": false,
  "api_host": "<http://localhost:3100>",
  "app_origin": "<http://35.233.230.197/:3000>",
  "config_source": "db",
  "email_enabled": false,
  "build": {
    "sha": "cb216a48fd0c9e2942d9003179895d3858e096dc",
    "date": "2022-05-17T13:24:04Z"
  }
}
f

fresh-football-47124

05/18/2022, 1:15 AM
looks like an extra /
w

wonderful-xylophone-6904

05/18/2022, 1:15 AM
whew that took care of it
thanks so much
f

fresh-football-47124

05/18/2022, 1:16 AM
fyi, that ip is public
w

wonderful-xylophone-6904

05/18/2022, 1:16 AM
yes it's a loadbalancer IP -- gets reassigned any time I delete my pods
doing that now
but thanks for helping me debug through this
29 Views