Error connecting to remote mysql through google cloud - mysql

After I run a command regarding the database, I get this:
{ SequelizeConnectionError: connect ETIMEDOUT ip:5432
at connection.connect.err (/Users/me/Documents/PetHotel/backend-sql/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:128:24)
at Connection.connectingErrorHandler (/Users/me/Documents/PetHotel/backend-sql/node_modules/pg/lib/client.js:140:14)
at Connection.emit (events.js:182:13)
at Socket.reportStreamError (/Users/me/Documents/PetHotel/backend-sql/node_modules/pg/lib/connection.js:71:10)
at Socket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process.internalTickCallback (internal/process/next_tick.js:72:19)
name: 'SequelizeConnectionError',
parent:
{ Error: connect ETIMEDOUT ip:5432
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1121:14)
errno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect',
address: 'ip',
port: 5432 },
original:
{ Error: connect ETIMEDOUT ip:5432
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1121:14)
errno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect',
address: 'ip',
port: 5432 } }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app-backend# db:reset:development: `cross-env MIGRATION_ENV=development node ./migrations/reset`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the app-backend# db:reset:development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Is it something regarding google I wonder? I do have set 0.0.0.0/0 as authorised ip

From the error, it seems your app is not able to connect to CloudSQL instance possibly due to network restriction.
Opening instance to 0.0.0.0/0 is not a good idea.
Google suggest different ways yo connect to CloudSQL Instance here. One particular method is sql-proxy.
Hope these guides helps you to establish connection between your app and cloudsql.

Related

Failed to download Chromium Set "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" env variable to skip download

I am trying to install polymer-cli version 3 in my Windows and I am getting the error mentioned in this question. Searching around I reach that it is a problem with kind of PDF Generator from NPM dependencies. Sincerely, it doesn't make sense to me but I still try follow the recommendation mentioned in https://github.com/webpro/reveal-md/issues/191.
Bellow, the full error:
C:\dev\polymer2\sample>npm install -g polymer-cli#next --no-optional
C:\Users\my-user\AppData\Roaming\npm\polymer -> C:\Users\my-user\AppData\Roaming\npm\node_modules\polymer-cli\bin\poly
mer.js
> puppeteer#1.3.0 install C:\Users\my-user\AppData\Roaming\npm\node_modules\polymer-cli\node_modules\puppeteer
> node install.js
ERROR: Failed to download Chromium r549031! Set "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" env variable to skip download.
{ Error: getaddrinfo ENOTFOUND storage.googleapis.com storage.googleapis.com:443
at errnoException (dns.js:50:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)
code: 'ENOTFOUND',
errno: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'storage.googleapis.com',
host: 'storage.googleapis.com',
port: 443 }
npm WARN rollback Rolling back debug#3.1.0 failed (this is probably harmless): EPERM: operation not permitted, scandir '
C:\Users\my-user\AppData\Roaming\npm\node_modules\polymer-cli\node_modules\puppeteer\node_modules\https-proxy-agent\nod
e_modules'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.3 (node_modules\polymer-cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.3: wanted {"os":"darwin","arch":"any
"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: puppeteer#1.3.0 (node_modules\polymer-cli\node_modules\puppeteer):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: puppeteer#1.3.0 install: `node install.js`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
+ polymer-cli#1.7.0-pre.17
updated 1 package in 15.762s
C:\dev\polymer2\sample>polymer --version
1.7.0-pre.17

Im unable to find the error with mysql code

I am newbie. i am not able to insert data from front end into mysql database. I am facing the problem at the time of insertion.
my index.js code
I'm storing the form details in a variable and trying to insert it into database
router.post('/signup',function(req,res,next) {
var item = req.body;
connection.connect(function(err){
var sql = "INSERT INTO details VALUES ? ";
connection.query(sql,[item]);
});
res.render('data' ,{items:item});
});
Error message
/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Parser.js:80
throw err; // Rethrow non-MySQL errors
^
Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`name` = 'Gayathri', `pwd` = 'def'' at line 1
at Query.Sequence._packetToError (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/sequences/Sequence.js:52:14)
at Query.ErrorPacket (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/sequences/Query.js:77:18)
at Protocol._parsePacket (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Protocol.js:279:23)
at Parser.write (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Parser.js:76:12)
at Protocol.write (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Protocol.js:39:16)
at Socket.<anonymous> (/home/gayathri/jsonhbs/node_modules/mysql/lib/Connection.js:103:28)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
--------------------
at Protocol._enqueue (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Protocol.js:145:48)
at Connection.query (/home/gayathri/jsonhbs/node_modules/mysql/lib/Connection.js:208:25)
at Handshake._callback (/home/gayathri/jsonhbs/routes/index.js:46:14)
at Handshake.Sequence.end (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/sequences/Sequence.js:88:24)
at /home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Protocol.js:225:14
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! jsonhbs#0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the jsonhbs#0.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! /home/gayathri/.npm/_logs/2017-10-18T03_54_05_403Z-debug.log
That's not valid SQL syntax. You can't use a placeholder for a bunch of values like that, you must break them out individually:
connection.query(
"INSERT INTO details (name, pwd) VALUES (?,?)",
[ "Name", "Pwd" ]
);
Supplying all those conditions as a single placeholder has the effect of encapsulating them inside a string, which breaks the syntax.
IMPORTANT: Always hash your passwords, never use plain-text to store them. At the absolute least use Bcrypt which is specifically intended for passwords and not some high-speed hash like SHA1 or a compromised hash like MD5.
If you're using Node you probably want to at least consider using Passport which can do a lot of the heavy lifting for you, and plays nicely with other Node components.

Access denied when connecting to localhost with node

I have an error when I try to start my code with node (npm start).
I have MySQL, XAMPP and node installed.
The error is as followed:
webpack building...
Server started on port 3000
/Users/RaphaelleG/Documents/SOEN343/node_modules/mysql/lib/protocol/Parser.js:80
throw err; // Rethrow non-MySQL errors
^
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'#'localhost' (using password: NO)
at Handshake.Sequence._packetToError (/Users/RaphaelleG/Documents/SOEN343/node_modules/mysql/lib/protocol/sequences/Sequence.js:52:14)
at Handshake.ErrorPacket (/Users/RaphaelleG/Documents/SOEN343/node_modules/mysql/lib/protocol/sequences/Handshake.js:103:18)
at Protocol._parsePacket (/Users/RaphaelleG/Documents/SOEN343/node_modules/mysql/lib/protocol/Protocol.js:279:23)
at Parser.write (/Users/RaphaelleG/Documents/SOEN343/node_modules/mysql/lib/protocol/Parser.js:76:12)
at Protocol.write (/Users/RaphaelleG/Documents/SOEN343/node_modules/mysql/lib/protocol/Protocol.js:39:16)
at Socket.<anonymous> (/Users/RaphaelleG/Documents/SOEN343/node_modules/mysql/lib/Connection.js:103:28)
at emitOne (events.js:115:13)
at Socket.emit (events.js:210:7)
at addChunk (_stream_readable.js:266:12)
at readableAddChunk (_stream_readable.js:253:11)
at Socket.Readable.push (_stream_readable.js:211:10)
at TCP.onread (net.js:585:20)
--------------------
at Protocol._enqueue (/Users/RaphaelleG/Documents/SOEN343/node_modules/mysql/lib/protocol/Protocol.js:145:48)
at Protocol.handshake (/Users/RaphaelleG/Documents/SOEN343/node_modules/mysql/lib/protocol/Protocol.js:52:23)
at PoolConnection.connect (/Users/RaphaelleG/Documents/SOEN343/node_modules/mysql/lib/Connection.js:130:18)
at Pool.getConnection (/Users/RaphaelleG/Documents/SOEN343/node_modules/mysql/lib/Pool.js:48:16)
at Object.<anonymous> (/Users/RaphaelleG/Documents/SOEN343/server/config/database.js:14:6)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/RaphaelleG/Documents/SOEN343/server/app.js:18:16)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tecmarket#0.1.0 start: `node ./server/app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tecmarket#0.1.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! /Users/RaphaelleG/.npm/_logs/2017-09-22T03_16_49_509Z-debug.log
Please can you help me resolve this error?

Polymer2.0 - polymer testing is failing with error

When I try to test polymer elements and run polymer test command, I am getting below error
Installing and starting Selenium server for local browsers
----------
selenium-standalone installation starting
----------
---
selenium install:
from: https://selenium-release.storage.googleapis.com/3.0/selenium-server-standa
lone-3.0.1.jar
to: C:\Users\xxxx\AppData\Roaming\npm\node_modules\polymer-cli\node_modules\se
lenium-standalone\.selenium\selenium-server\3.0.1-server.jar
---
chrome install:
from: https://chromedriver.storage.googleapis.com/2.27/chromedriver_win32.zip
to: C:\Users\xxxx\AppData\Roaming\npm\node_modules\polymer-cli\node_modules\se
lenium-standalone\.selenium\chromedriver\2.27-x64-chromedriver
---
ie install:
from: https://selenium-release.storage.googleapis.com/2.53/IEDriverServer_x64_2.
53.1.zip
to: C:\Users\xxxx\AppData\Roaming\npm\node_modules\polymer-cli\node_modules\se
lenium-standalone\.selenium\iedriver\2.53.1-x64-IEDriverServer.exe
---
firefox install:
from: https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriv
er-v0.11.1-win64.zip
to: C:\Users\xxxx\AppData\Roaming\npm\node_modules\polymer-cli\node_modules\se
lenium-standalone\.selenium\geckodriver\0.11.1-x64-geckodriver
Error: Could not download https://selenium-release.storage.googleapis.com/3.0/se
lenium-server-standalone-3.0.1.jar: Error: connect ETIMEDOUT xxx.xxx.x.xx:443
error: cli runtime exception: Error: Could not download https://selenium-relea
se.storage.googleapis.com/3.0/selenium-server-standalone-3.0.1.jar: Error: conne
ct ETIMEDOUT xxx.xxx.x.xx:443
error: Error: Could not download https://selenium-release.storage.googleapis.c
om/3.0/selenium-server-standalone-3.0.1.jar: Error: connect ETIMEDOUT xxx.xxx.x.xx:443
at Request.<anonymous> (C:\Users\xxxx\AppData\Roaming\npm\node_modules\pol
ymer-cli\node_modules\selenium-standalone\lib\install.js:286:12)
at Request.g (events.js:292:16)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at Request.onRequestError (C:\Users\xxxx\AppData\Roaming\npm\node_modules\
polymer-cli\node_modules\selenium-standalone\node_modules\request\request.js:845
:8)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at TLSSocket.socketErrorListener (_http_client.js:309:9)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:188:7)
For security reasons, masked IP address with 'x'
Note: I am using proxy and it is available in .bowerrc file and other bower downloads are fine without any issue

Unable to build Sitecore Habitat solution

I tried to set up Sitecore Habitat solution by using the default configuration but unfortunately when i try the third task Publish All Projects the build fails showing the below error:
> cmd.exe /c gulp -b "C:\Projects\Habitat" --color --gulpfile "C:\Projects\Habitat\Gulpfile.js" 03-Publish-All-Projects
[11:12:23] Using gulpfile C:\Projects\Habitat\Gulpfile.js
[11:12:23] Starting '03-Publish-All-Projects'...
[11:12:23] Starting 'Build-Solution'...
[11:12:23] Using automatic maxcpucount
[11:12:23] { [Error: spawn ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn' }
[11:12:23] Build failed!
[11:12:23] 'Build-Solution' errored after 101 ms
[11:12:23] Error: spawn ENOENT
at errnoException (child_process.js:1001:11)
at Process.ChildProcess._handle.onexit (child_process.js:792:34)
[11:12:23] '03-Publish-All-Projects' errored after 112 ms
[11:12:23] Error in plugin 'run-sequence(Build-Solution)'
Message:
spawn ENOENT
Details:
code: ENOENT
errno: ENOENT
syscall: spawn
Stack:
Error: spawn ENOENT
at errnoException (child_process.js:1001:11)
at Process.ChildProcess._handle.onexit (child_process.js:792:34)
Process terminated with code 1.
The enviorement that i have set up is identical as described on the following link https://github.com/Sitecore/Habitat/wiki/01-Getting-Started.
Seems like npm modules gulp is not found.
If you have installed npm module add the following to the path in the environment varriable:%AppData%\npm
Note: Do not forget to close and re-open cmd (or VS2015).