1

I want to use the memcache AppEngine service in my NodeJS flexible environment. As specified in the documentation: https://cloud.google.com/appengine/docs/flexible/nodejs/using-redislabs-memcache

I used the suggested app.yaml file and I decommented the USE_GAE_MEMCACHE: 1 and commented the other variables. But when I run my deploy command it fails with this error:

net.js:1048
      throw new RangeError('"port" option should be >= 0 and < 65536: ' + port);
      ^

RangeError: "port" option should be >= 0 and < 65536: NaN
    at lookupAndConnect (net.js:1048:13)
    at Socket.connect (net.js:1021:5)
    at Object.connect (net.js:113:35)
    at Server.sock (/app/node_modules/memjs/lib/memjs/server.js:120:24)
    at Server.write (/app/node_modules/memjs/lib/memjs/server.js:219:8)
    at handleFlush (/app/node_modules/memjs/lib/memjs/memjs.js:620:10)
    at Client.flush (/app/node_modules/memjs/lib/memjs/memjs.js:624:5)
    at MemcachedDriver.flush (/app/data_manager/memcached_driver.js:42:17)
    at Storage.intialize (/app/data_manager/storage.js:45:12)
    at Object.<anonymous> (/app/app.js:22:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! waternamics@1.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the waternamics@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-07-26T14_39_48_624Z-debug.log

When I log the MEMCACHE_URL variable it says: undefined:undefined Here's the code I am using to connect to memcache:

let MEMCACHE_URL = process.env.MEMCACHE_URL || '127.0.0.1:11211';

    if (process.env.USE_GAE_MEMCACHE) {
        MEMCACHE_URL = `${process.env.GAE_MEMCACHE_HOST}:${process.env.GAE_MEMCACHE_PORT}`;
    }

    this.client = Memcached.Client.create(MEMCACHE_URL);

I don't know why it didn't work, It specs in the documentation that it's in alpha but it should work no ?

Mehdi Benmoha
  • 3,694
  • 3
  • 23
  • 43

1 Answers1

0

For using Memcache with App Engine flex you need to sign up this form to get access to the alpha. [Memcache flex form] (It may take some time).

Alternatively, you can choose between setup your own Memcache (Redis, etc) or use Memcache for App Engine Standard environment.

J.L Valtueña
  • 403
  • 2
  • 11
  • How can I use it for standard environment ? – Mehdi Benmoha Jul 27 '18 at 10:45
  • You can follow this doc https://cloud.google.com/appengine/docs/standard/python/memcache/using (Python |Java |PHP |Go) AND this https://cloud.google.com/appengine/docs/standard/python/memcache/examples (only Python). – J.L Valtueña Jul 27 '18 at 11:12
  • You are right, but still have some options like filling the form or use a 3rd party product. – J.L Valtueña Jul 27 '18 at 12:28
  • I expected that Google announced new features during Google Cloud Next 18 but they didn't it. My understanding is that nodejs standard is not able to use GAE's embedded memcache for now. And also it is not able to use memorystore, managed redis, from GAE standard because of VPC. I think it is difficult to choose GAE nodejs standard so far. Can you correct me if I'm missing something? – zono Jul 29 '18 at 01:05
  • It's true that Memcache is not currently available for use with Node.js on App Engine Standard. I've opened a [feature request](https://issuetracker.google.com/issues/112072322) on your behalf with regards to this. You can 'star' the issue to keep track of it if you wish – Christopher P Aug 01 '18 at 13:43