2

I am using protractor 52.2 and cucumber 3.2.2. I am using selenium grid(selenium-server-standalone-3.14.0.jar) with the protractor and running my script in 4 browsers of 4 different nodes. I have a table of 600 rows in the DB. Initially, I am accessing data from this table and entering the data of each row through my protractor script and updating the DB column after successful entering of each row. But after entering some rows successfully, protractor script abruptly ends with error "ConnectionError: Connection lost - read ECONNRESET in protractor".And I am getting an error message in update SQL query, that "RequestError: Resource ID: 1. The request limit for the database is 60 and has been reached. See 'http://go.microsoft.com/fwlink/?LinkId=267637' for assistance." The update query which I am using is given below(i am using azure sql). I am not getting a clear idea of how to solve this. Thanks in advance.

var Connection = require('tedious').Connection;
var Request = require('tedious').Request;
var config = 
{
 userName: 'xxx', 
 password: 'xxxxx', 
 server: 'xxxxxx', 
 options: 
    {
       database: 'xxx' ,
       encrypt: true,
       rowCollectionOnRequestCompletion: true
    }
}
var connection = new Connection(config);

defineSupportCode(function ({ setDefaultTimeout, Given, When, Then }) {
 setDefaultTimeout(30000 * 1000);
   function updatedb(LPAID){
      request = new Request("UPDATE COM_Location_Post with (rowlock) SET IsPublished = 1 WHERE Id ="+LPAID,function(err,rowCount, rows) { 
        if(err){
          console.log(err)
         }
      });
     connection.execSql(request);
  }
});
Devleena
  • 453
  • 9
  • 25

1 Answers1

1

You did not use connection close in your script.

By your question its clear after max instance you face this problem.

Try closing your connection every time for each transaction.

    (async () => {
            const config = {
                user: 'User',
                password: 'iPg$',
                server: 'cp-sql',
                database: 'DBI',
                options: {
                    encrypt: true // Use this if you're on Windows Azure
                }
            }
            try {

                let pool = await sql.connect(config)
                var envcode, testcode;
                let result1 = await pool.request()
                    .query(`query 1 goes here`)
                // console.dir(result1)
                pool.close();
                sql.close();
                let pool1 = await sql.connect(config)
                let result2 = await pool1.request()
                    .query(`query 2 goes here`)
                // console.dir(result2)
                pool1.close();
                sql.close();
                resolve(result2);
            } catch (err) {
                console.log(err)
            }
        })()
Bharath Kumar S
  • 1,410
  • 2
  • 10
  • 29
  • Thanks for your reply..Can you please share how can i use connection close in this query. – Devleena Oct 26 '18 at 03:55
  • Edited the answer @devleena. You should get types support for your connection after executing your query try to see if connection shows a method close(). – Bharath Kumar S Oct 26 '18 at 04:16
  • After displaying my recordset i have used conn.close to kill the connection instance. – Bharath Kumar S Oct 26 '18 at 04:18
  • i have use connection close in my sql query as connection.on('connect', function (err) { if (err) { reject(err); connection.close(); }else { request1 = new Request("EXEC [usp_GetPostDetails_Automation] "+clientID+"," + thread, function (err, rowCount, rows) { if (err) { reject(err); connection.close(); }else { resolve('done'); connection.close(); } }); connection.execSql(request1); } }); This one successfully executed, But when i am trying to connect next query same as like this,it is not executing next query. – Devleena Oct 26 '18 at 07:37
  • After executing the first query, the process get exit..so do we have another syntax to reconnection? by using 'connection.on' ,it is not working in second time.Do you have any idea? – Devleena Oct 26 '18 at 07:39
  • Edited the answer . Good luck – Bharath Kumar S Oct 26 '18 at 07:57