Random occurrences of Failed: ECONNREFUSED connect ECONNREFUSED 127.0.0.1 when running protractor tests - node.js

My protractor test cases randomly fail with this error message:
Failed: ECONNREFUSED connect ECONNREFUSED 127.0.0.1
I have gone through the resources and tried all the suggested solutions:
Upgraded protractor
Ran webdriver-manager update
Upgraded chromedriver version but the issue seems to exist.
This particularly happens when I try to run all the e2e tests together.
Below is the specific versions that Im using for my project:
node - v9.2.0
protractor - Version 5.4.1
ChromeDriver 2.42.591088
Please help.
Thanks,
Neeraja

Are you using async/await in your tests?
Can you try applying patch as specified below from the same folder which contains the 'node_modules' folder by executing 'node patch.js'?
patch.js file
var fs = require('fs');
var httpIndexFile = 'node_modules/selenium-webdriver/http/index.js';
fs.readFile(httpIndexFile, 'utf8', function (err, data) {
if (err)
throw err;
var result = data.replace(/\(e.code === 'ECONNRESET'\)/g, "(e.code === 'ECONNRESET' || e.code === 'ECONNREFUSED')");
console.log(`Patching ${httpIndexFile}`)
fs.writeFileSync(httpIndexFile, result, 'utf8');});
var chromeFile = 'node_modules/selenium-webdriver/chrome.js';
fs.readFile(chromeFile, 'utf8', function (err, data) {
if (err)
throw err;
var result = data.replace(/new http.HttpClient\(url\)/g, "new http.HttpClient(url, new (require('http').Agent)({ keepAlive: true }))");
console.log(`Patching ${chromeFile}`)
fs.writeFileSync(chromeFile, result, 'utf8');});
Please see original post here -
https://github.com/angular/protractor/issues/4706#issuecomment-393004887

Related

Unspecified System Error using nodejs driver to connect to informix

I have this connection below. Works well in windows server but when in linux it doesnt. It provides this erro msg :an error occured:> Error: [Informix][Informix ODBC Driver][Informix]Unspecified System Error = -23101.
when I check on the error code using finderr it says the locale environment variables DB_LOCALE and CLIENT_LOCALE has problem how do I go about this? How can I set the locales or find the problem and solve it. Note that I have installed the CSDK and set the environment varibales as required my connection is as below code.
var ibmdb = require("ifxnjs");
var ConnectionString = "SERVER=ict_tcp;DATABASE=biolive;HOST=128.1.9.144;SERVICE=1541;UID=biouser;PWD=bihif20;";
ibmdb.open(ConnectionString, function (err, connection) {
if (err)
{
console.log("an error occured:> "+err);
return;
}
connection.query("select 1 from mytab1", function (err1, rows)
{
if (err1) console.log(err1);
else console.log(rows);
connection.close(function(err2)
{
if(err2) console.log(err2);
});
});
});
The problem was that my CSDK files were not complete I did not have the gls(global locale support) folder, which provides language support for informix .Incase you know you have set the environment variables properly but still get errors, try checking your CSDK files if all are installed properly or some are missing.

'process.nextTick(function() { throw err; })' - Undefined is not a function (mongodb/mongoose)

I'm trying to connect to my mongodb using nodejs and socket.io. I am able to connect to the database because I get 'connection accepted' in my console but on the nodejs side, as soon as I - indeed - get
Connection to mongodb://localhost:27017 established through mongoose
it immediately fails next with
process.nextTick(function() { throw err; }) ^TypeError: undefined is
not a function at showCollections**
And here goes showCollections:
var showCollections = function(db, callback) {
mongoose.connection.db.collectionNames(function(error, names) {
if (error) {
throw new Error(error);
} else {
console.log("=>Listening mongo collections:");
names.map(function(cname) {
mongoose.connection.db.dropCollection(cname.name);
console.log("--ยป"+cname.name);
});
}
});
}
And here is the content of my database folder:
_tmp (empty folder)
local.0
local.ns
mongod.lock
I run the mongodb by typing mongod --dbpath folder and it successfully 'awaits connections on port 27017'.
Also, my node_modules from package.json (npm)
"dependencies": {
"express": "^4.9.6",
"socket.io": "latest",
"mongodb": "~2.0",
"mongoose": "*"
}
Thank you very much for your help...
StackTrace:
> TypeError: undefined is not a function
> at showCollections (/usr/share/nginx/www/index.js:77:25)
> at NativeConnection.callback (/usr/share/nginx/www/index.js:46:3)
> at NativeConnection.g (events.js:199:16)
> at NativeConnection.emit (events.js:104:17)
> at open (/usr/share/nginx/www/node_modules/mongoose/lib/connection.js:485:10)
> at NativeConnection.Connection.onOpen (/usr/share/nginx/www/node_modules/mongoose/lib/connection.js:494:5)
> at /usr/share/nginx/www/node_modules/mongoose/lib/connection.js:453:10
> at /usr/share/nginx/www/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js:59:5
> at /usr/share/nginx/www/node_modules/mongoose/node_modules/mongodb/lib/db.js:200:5
> at connectHandler (/usr/share/nginx/www/node_modules/mongoose/node_modules/mongodb/lib/server.js:272:7)
EDIT:
I'm as well having these problems when trying to run the nodejs instance:
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
I tried fixing them as other questions here would tell but nothing worked either...
From the provided information, it looks like you are using mongodb 2.0 driver. The db.collectionNames method was dropped. Check out the "Db Object" section of this page - https://github.com/mongodb/node-mongodb-native/blob/0642f18fd85037522acf2e7560148a8bc5429a8a/docs/content/tutorials/changes-from-1.0.md#L38
They've replaced it with listCollections. You should get the same effect with:
mongoose.connection.db.listCollections().toArray(function(err, names) {
if (err) {
console.log(err);
}
else {
names.forEach(function(e,i,a) {
mongoose.connection.db.dropCollection(e.name);
console.log("--->>", e.name);
});
}
});
For me this error started popping up when i had to force shut down my pc as it became unresponsive. Next time i started my express server this error popped up. I solved it by running npm install mongoose#4.0 --save in the terminal.
May be this error pops up when your server or database is force closed and some code is not save in mongod behind the scenes.
Shouldn't you specify the full path and have an export module?...something like:
mongoose.connection.db.collectionNames(function (err, names)
{
console.log(names); // [{ name: 'dbname.myCollection' }]
module.exports.Collection = names;
}
If I'm wrong it's because I don't fancy moongodb :)

Nodejs GM module ImageMagick - strange Error

I have a very strange error. I'm using MAC OS X 10.9.5.
When i use some functions from GM (npm install gm) like resize or something else i got this error.
events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn ENOENT
at errnoException (child_process.js:988:11)
at Process.ChildProcess._handle.onexit (child_process.js:779:34)
I have found many threads about it and according to them i have installed graphicksmagic and imagemagick with brew to system.
brew install imagemagick
brew install graphicsmagick
It was working for a while but for no reason it starts to showing the above error again.
I checked that i have installed imagemagick and graphicksmagick in system and its working from terminal.
I checked if i have it in $PATH and its there.
If i run this in nodejs it shows correct version of imagemagick in console, so i assume path is ok in nodejs.
var sys = require('sys')
var exec = require('child_process').exec;
function puts(error, stdout, stderr) {
if(error)
sys.puts(error);
if(stderr)
sys.puts(stderr);
sys.puts(stdout);
}
exec("identify --version", puts);
This is code which is crashing:
gm(request(url), thumbName)
.resize('300', '300', '^')
.gravity('Center')
.crop('300', '300')
.toBuffer('JPG',function (err, buffer) {
var data = {
Bucket: bucket,
Key: thumbName,
Body: buffer,
ACL:'public-read',
ContentType: 'image/jpeg'
};
s3.putObject(data, function(err, res) {
....
});
Everything is working when i deploy it on heroku
IF someone will have this issue i solved it.
I add variable PATH to enviroment variables in node with this value
bin:node_modules/.bin:/usr/local/bin:/usr/bin:/bin

Node JS Error: Cannot find module './build/Release/mysql_bindings'

I have installed Node.Js and Casper.js to perform webscraping and save the info into a DB. But I have a problem because when I try to execute the source, I get the following error in the terminal:
Error: Cannot find module './build/Release/mysql_bindings'
I have previously installed mysql-libmysqlclient with the mysql_bindings inside. I tested creating the route of the error, but it didn't work.
The code is:
var mysql = require('db-mysql');
new mysql.Database({
hostname: 'localhost',
user: 'rool',
password: 'xxxx',
database: 'xxxBD' }).connect(function(error) {
if (error) {
return console.log('CONNECTION error: ' + error);
}
this.query().
select('*').
from('tablaPruebas').
execute(function(error, rows, cols) {
if (error) {
console.log('ERROR: ' + error);
return;
}
console.log(rows.length + ' ROWS found');
});
});
Thanks in advance!
The problem is that your using the following in your code:
var mysql = require('db-mysql');
However your question shows that you have installed mysql-libmysqlclient. This means you should be using the following instead:
var mysql = require('mysql-libmysqlclient');
I presume you installed from https://github.com/Sannis/node-mysql-libmysqlclient
The code you're using looks more like db-mysql which can be found here
If you install via npm install db-mysql then you should be good. Have a look at the link I included for db-mysql as there appears to be a few dependencies (e.g. setting up MYSQL_CONFIG environment variable).

Node.js SQL Server driver issue - How to troubleshoot

What is the correct way to troubleshoot this error with Node.js on Windows with the SQL Server driver.
events.js:2549: Uncaught Error: 42000: [Microsoft][SQL Server Native Client 11.0
]Syntax error, permission violation, or other nonspecific error
It is not the SQL statement - it works in other tools - like .NET
Doesn't seem to be the SQL connection info - it works in other tools - like .NET
Any thoughts? What is the correct way for completely uninstalling node.js and starting over. I don't think my last install removed all my global modules.
var sql = require('node-sqlserver');
var _ = require('underscore')._;
var connstr = "Driver={SQL Server Native Client 11.0};Server=localhost;" +
"Initial Catalog=CDDB;Trusted_Connection={Yes}";
sql.open(connstr, function (err, conn) {
if (err) {
console.log("Error opening the connection");
return;
} else {
var stmt = "select top 10 * from Client";
conn.query(connstr, stmt, function (err, results) {
if (err) {
console.log("Error running query!");
return;
}
_.each(results, function (row) {
console.log(row[0]);
});
});
}
});
First idea : Are users which runs your node.exe process and the one defined on your application pool - or maybe your current user account if you are using VS.NET to check your code are the same ?
To troubleshoot :
I would use node-inspector - it allows to set up breakpoints onto your node.js code
To install it :
npm install -g node-inspector
To run it :
node --debug your-nodeapp-file.js
Launch another command line and run the following program :
node-inspector
Sorry but i do not have SQL Server to try your code, hope this help anyway.

Resources