x-devapi unable to connect to database in Google app-engine

Multi tool use
Multi tool use


x-devapi unable to connect to database in Google app-engine



I am deploying a simple nodejs server to App-engine which works well except for the database connection using the X-devapi. I am getting this error:


nodejs


X-devapi



All routers failed.


All routers failed.



Here is the code I use:


'use strict';

const express = require('express');
const mysqlx = require('@mysql/xdevapi');

const app = express();
app.get('/', (req, res) => {
const options = { user: 'user_name', password: '@pass',host: 'XX.XXX.XX.XXX'
/*Here I used Public IP address on the of the SQL instance*/,port: XXXX
/*I assigned port 8080 here*/, schema: 'db_name' };

(async function () {
let session;

try {
session = await mysqlx.getSession(options);

const collection = await session.getSchema(options.schema).createCollection('collection');
await collection.add({ name: 'foo' }).execute();
await collection.find().fields('name').execute(console.log); // { name: 'foo' }
} catch (err) {
//console.error(err.message);
res.status(200).send(err.message).end();//used code 200 in order to receive the error too
} finally {
session && session.close();
}
})();
});

// Start the server
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`App listening on port ${PORT}`);
console.log('Press Ctrl+C to quit.');
});



How can I solve this?





The error basically means the server can't be reached. So either or both the host or the port properties used to create the session don't match the MySQL server instance. Also, I assume you are somehow running MySQL on port 8080 in a different host (probably using --port=8080). I'm not familiar with Google App Engine, can you even have that kind of control? If not, maybe you need to use the default X Protocol port (33060), and that is, of course, if the MySQL version available actually supports the X Protocol.
– ruiquelhas
12 hours ago


--port=8080





You are right, check the answer am posting next, from Google support
– Geek Guy
21 mins ago




1 Answer
1



It turns out that Google cloud SQL tools still do not have the X devAPI enabled if you check response to my concern here and the feature request here


X devAPI






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

65jL acWeIRiAe0GjRuKGFN Mh9oTOv wlbPvVvAlzfb XfD5g62rV4 AtTYMbA7Q fAmD5tLq
5E Ly7Xw JSY0OyvkZwvlWPTa7498icDT4WQl0OErdZ,aaO8,QN HbhJFT 7s 5Pi4Qf23foCvp jHwd4eSxv4cGPNpDt1OchFBnRrC1

Popular posts from this blog

Rothschild family

Cinema of Italy