how to close the cassandra connection when using connection pooling ?

712 views
Skip to first unread message

Nitika

unread,
Sep 23, 2016, 10:09:58 AM9/23/16
to DataStax Node.js Driver for Apache Cassandra Mailing List
im trying to use shutdown .
client.shutdown. But that seems to work sometimes but most of the times gives error .

{ [Error: All host(s) tried for query failed. First host tried, 52.90.250.73:9042: Error: Socket was closed. See innerErrors.]
  innerErrors:
   { '10.0.1.1:9042':
      { [Error: Socket was closed]
        message: 'Socket was closed',
        info: 'Cassandra Driver Error',
        isSocketError: true,
        wasRequestWritten: true,
        coordinator: '10.0.1.1:9042' },
     '127.0.0.1:9042':
      Error: Pool is being closed when calling create
   at HostConnectionPool.create (/mnt/copycode/node_modules/cassandra-driver/lib/host-connection-pool.js:109:21)
          at HostConnectionPool.borrowConnection (/mnt/copycode/node_modules/cassandra-driver/lib/host-connection-pool.js:66:8)
          at Host.borrowConnection (/mnt/copycode/node_modules/cassandra-driver/lib/host.js:207:13)
          at RequestHandler.getPooledConnection (/mnt/copycode/node_modules/cassandra-driver/lib/request-handler.js:121:8)
          at RequestHandler.iterateThroughHosts (/mnt/copycode/node_modules/cassandra-driver/lib/request-handler.js:92:8)
          at RequestHandler.getNextConnection (/mnt/copycode/node_modules/cassandra-driver/lib/request-handler.js:56:17)
          at RequestHandler.send (/mnt/copycode/node_modules/cassandra-driver/lib/request-handler.js:158:8)
          at RequestHandler.retry (/mnt/copycode/node_modules/cassandra-driver/lib/request-handler.js:402:8)
          at RequestHandler.handleError (/mnt/copycode/node_modules/cassandra-driver/lib/request-handler.js:324:15)
          at readCallback (/mnt/copycode/node_modules/cassandra-driver/lib/request-handler.js:179:19) },


Please suggest the best practice

Jorge Bay Gondra

unread,
Sep 23, 2016, 10:16:26 AM9/23/16
to nodejs-dr...@lists.datastax.com
Hi,
You should call shutdown() once in your application lifetime (ie: when shutting down your application): https://github.com/datastax/nodejs-driver/tree/master/doc/faq#should-i-shut-down-the-pool-after-executing-a-query

You should share a single client instance across your application: https://github.com/datastax/nodejs-driver/tree/master/doc/coding-rules#client


Hope it helps,
Jorge

--
You received this message because you are subscribed to the Google Groups "DataStax Node.js Driver for Apache Cassandra Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs-driver-user+unsub...@lists.datastax.com.

Reply all
Reply to author
Forward
0 new messages