2
votes

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);
  }
});
1

1 Answers

1
votes

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)
            }
        })()