This socket has been ended by the other party
Hey, I just got an error This socket has been ended by the other party
on the version 0.15.8. I found similar issue https://github.com/sidorares/node-mysql2/issues/57.
Not sure if I can reproduce it again to grab some example. Please let me know if it's needed I'll try. Thanks.
This socket has been ended by the other party at Socket.writeAfterFIN as write at Connection.write (/app/node_modules/mysql2/lib/connection.js:136:15) at Connection.writePacket (/app/node_modules/mysql2/lib/connection.js:150:10) at Query.start (/app/node_modules/mysql2/lib/commands/query.js:39:14) at Query.Command.execute (/app/node_modules/mysql2/lib/commands/command.js:34:20) at Connection.handlePacket (/app/node_modules/mysql2/lib/connection.js:310:28) at Connection.addCommand (/app/node_modules/mysql2/lib/connection.js:326:10) at Connection.query (/app/node_modules/mysql2/lib/connection.js:397:15) at Connection.wrapped (/app/node_modules/newrelic/lib/transaction/tracer/index.js:155:28) at Connection.wrappedFunction as query at /app/node_modules/knex/lib/dialects/mysql/index.js:92:18 at tryCatcher (/app/node_modules/knex/node_modules/bluebird/js/main/util.js:26:23) at Promise._resolveFromResolver (/app/node_modules/knex/node_modules/bluebird/js/main/promise.js:480:31) at new Promise (/app/node_modules/knex/node_modules/bluebird/js/main/promise.js:70:37) at Client._query (/app/node_modules/knex/lib/dialects/mysql/index.js:88:12) at Client.query (/app/node_modules/knex/lib/client.js:136:24) at Runner.
(/app/node_modules/knex/lib/runner.js:115:24) at Runner.tryCatcher (/app/node_modules/knex/node_modules/bluebird/js/main/util.js:26:23) at Runner.query (/app/node_modules/knex/node_modules/bluebird/js/main/method.js:15:34) at /app/node_modules/knex/lib/runner.js:43:21 at /app/node_modules/knex/node_modules/bluebird/js/main/using.js:176:30 at wrapped (/app/node_modules/newrelic/lib/transaction/tracer/index.js:155:28) at tryCatcher (/app/node_modules/knex/node_modules/bluebird/js/main/util.js:26:23) at Promise._settlePromiseFromHandler (/app/node_modules/knex/node_modules/bluebird/js/main/promise.js:507:31) at Promise._settlePromiseAt (/app/node_modules/knex/node_modules/bluebird/js/main/promise.js:581:18) at Promise._settlePromises (/app/node_modules/knex/node_modules/bluebird/js/main/promise.js:697:14) at Async._drainQueue (/app/node_modules/knex/node_modules/bluebird/js/main/async.js:123:16) at Async._drainQueues (/app/node_modules/knex/node_modules/bluebird/js/main/async.js:133:10)
interesting. The expected behaviour of client connection is is stream is terminated ( 'end', or 'error' events ) then 1) if it's expected termination ( one after conn.end() ) nothing happens 2) if it's unexpected ( say, you switch wifi off ) connection emits 'error' event on connection object and an all queued commands.
writeAfterFin / Connection.writePacketindicate that somehow either connection error was ignored or command queue was not emptied on error
@dnfrolov , if you can reproduce same error - could you add error event handler to connection and to all command callbacks ( via query() or execute() callbacks ) ?
I think I can reproduce this by simply the shutting down the server. I don't see any difference in behavior depending on whether I shut it nicely or kill -9 the container so, at least we are probably not dealing with some corner case of something.
Fun note: I also run it under knex/pool2, and the first error bubbles up to knex as Knex:warning - Pool2 - Error: This socket has been ended by the other party. After that it seems to take POOL_SIZE amount of retries (returning the same error) before the a valid connection is actually reestablished. Might be pool related, too. The old 'mysql' driver handles the same case with nothing but "expected" errors.
Have this issue been located and solved? I also have this issue in my application, but I cannot reproduce this issue.
@PrinC no, unfortunately not ( and I can''t replicate it )
I'm also getting the same error:
Error: This socket has been ended by the other party at Socket.writeAfterFIN [as write] (net.js:270:12) at Client.send (_debug_agent.js:168:15) at _debug_agent.js:55:14 at Array.forEach (native) at DebugAPI.Agent.binding.onmessage (_debug_agent.js:54:18)
@Hosar are you using connection pool? what is mysql server version?
I think I can reproduce. Happens when command is sent from client and connection is close during the time command is being sent. I'm reproducing by sending long query ( via LOCAL INFILE and custom slow stream ) and connecting to forwarded portssh -L 3306:127.0.0.1:3307 laplace@localhost and killing ssh mid query
I think #57 and #38 are related, investigating this
If a connection not be used in a long time (such as 8 hours), you will meet the error。