Friday, May 5, 2017

[google-cloud-sql-discuss] Re: #nodejs #2ndGen Error: connect ETIMEDOUT

Hi, did you resolve this issue?

I am experiencing a similar situation where I can locally connect the NodeJS app to Google SQL (via the cloud proxy) but deploying to GAE throws a connection error.

It appears that the connection is closed during the handshake process:

<-- HandshakeInitializationPacket
HandshakeInitializationPacket {
  protocolVersion: 10,
  serverVersion: '5.7.14-google-log',
  threadId: 5596,
  scrambleBuff1: <Buffer 14 4a 4e 33 14 49 2c 0e>,
  filler1: <Buffer 00>,
  serverCapabilities1: 63487,
  serverLanguage: 33,
  serverStatus: 2,
  serverCapabilities2: 49663,
  scrambleLength: 21,
  filler2: <Buffer 00 00 00 00 00 00 00 00 00 00>,
  scrambleBuff2: <Buffer 6b 5a 26 35 34 65 23 01 6c 51 7b 36>,
  filler3: <Buffer 00>,
  pluginData: 'mysql_native_password',
  protocol41: true }

--> ClientAuthenticationPacket
ClientAuthenticationPacket {
  clientFlags: 455631,
  maxPacketSize: 0,
  charsetNumber: 33,
  filler: undefined,
  user: *****,
  scrambleBuff: <Buffer f3 9e 6e dc 09 0b 2e 2a b0 70 d9 9a c1 b2 39 53 31 ac c8 2b>,
  database: *****,
  protocol41: true }

Connection fails: Error: Connection lost: The server closed the connection.
It will be retried for the next request.
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: Connection lost: The server closed the connection.
    at Protocol.end (/app/node_modules/mysql/lib/protocol/Protocol.js:109:13)
    at Socket.<anonymous> (/app/node_modules/mysql/lib/Connection.js:109:28)
    at emitNone (events.js:91:20)
    at Socket.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)


On Thursday, September 8, 2016 at 9:45:22 AM UTC-7, Lekooa Dev wrote:
In fact, the original error comes from the first connection creation after the Node.js application starts: 

{ Error: Connection lost: The server closed the connection.
2016-09-08 15:32:39 default[20160908t164127]      at Protocol.end (/app/node_modules/mysql/lib/protocol/Protocol.js:109:13)
2016-09-08 15:32:39 default[20160908t164127]      at Socket.<anonymous> (/app/node_modules/mysql/lib/Connection.js:115:28)
2016-09-08 15:32:39 default[20160908t164127]      at emitNone (events.js:91:20)
2016-09-08 15:32:39 default[20160908t164127]      at Socket.emit (events.js:185:7)
2016-09-08 15:32:39 default[20160908t164127]      at endReadableNT (_stream_readable.js:974:12)
2016-09-08 15:32:39 default[20160908t164127]      at _combinedTickCallback (internal/process/next_tick.js:74:11)
2016-09-08 15:32:39 default[20160908t164127]      at process._tickCallback (internal/process/next_tick.js:98:9)
2016-09-08 15:32:39 default[20160908t164127]      --------------------
2016-09-08 15:32:39 default[20160908t164127]      at Protocol._enqueue (/app/node_modules/mysql/lib/protocol/Protocol.js:141:48)
2016-09-08 15:32:39 default[20160908t164127]      at Protocol.handshake (/app/node_modules/mysql/lib/protocol/Protocol.js:52:41)
2016-09-08 15:32:39 default[20160908t164127]      at PoolConnection.connect (/app/node_modules/mysql/lib/Connection.js:136:18)
2016-09-08 15:32:39 default[20160908t164127]      at Pool.getConnection (/app/node_modules/mysql/lib/Pool.js:48:16)
2016-09-08 15:32:39 default[20160908t164127]      at Promise (/app/node_modules/typeorm/driver/mysql/MysqlDriver.js:205:27)
2016-09-08 15:32:39 default[20160908t164127]      at MysqlDriver.retrieveDatabaseConnection (/app/node_modules/typeorm/driver/mysql/MysqlDriver.js:204:20)
2016-09-08 15:32:39 default[20160908t164127]      at MysqlDriver.<anonymous> (/app/node_modules/typeorm/driver/mysql/MysqlDriver.js:101:51)
2016-09-08 15:32:39 default[20160908t164127]      at next (native)
2016-09-08 15:32:39 default[20160908t164127]      at /app/node_modules/typeorm/driver/mysql/MysqlDriver.js:7:65
2016-09-08 15:32:39 default[20160908t164127]      at __awaiter (/app/node_modules/typeorm/driver/mysql/MysqlDriver.js:3:12) fatal: true, code: 'PROTOCOL_CONNECTION_LOST' }



I also forgot to indicate that the different MySQL connection options:
  • locally (working)
    • host: <MySQL_instante_remote_IP_address>
    • port: 3306
    • username: root
    • password: <root_password>
    • database: <database_name>
  • on App Engine (not working)
    • host: localhost
    • port : 3306
    • username: root
    • password: <root_password>
    • database: <database_name>
    • socketPath: "/cloudsql/{projectName}:{zone}:{instance-name}"

On Thursday, September 8, 2016 at 3:41:27 PM UTC+2, Lekooa Dev wrote:
Hello!

I'm currently developing a Node.js application (Express framework and TypeORM) with MySQL Second Generation. 

When the Node.js application runs on a local machine, they are any problem to connect and use the MySQL instance. 

But when the Node.js application is deployed on the App Engine, I have this following error "Error: connect ETIMEDOUT" after each query.

Thanks for you help!

----

Dockerfile:
# Use the base App Engine Docker image, based on debian jessie.
FROM gcr
.io/google_appengine/nodejs
# Install specific node.js version
RUN install_node v6
.5.0
# Copy application code.
COPY
. /app/
WORKDIR
/app
# Set common env vars
ENV NODE_ENV dev
 
# Install dependencies.
RUN npm
--unsafe-perm install
# start
CMD
["npm", "start"]

app.yaml:
# [START app_yaml]
#runtime: nodejs
runtime
: custom
vm
: true
beta_settings
:
      cloud_sql_instances
: "<cloud-sql-instance-name>"
# [END app_yaml]

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/3d246bf4-75cc-4144-9798-a249c914713f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment