Vinyl-ftp strange error - gulp

I am using Vinyl-ftp to do deployment, when i try to connect with FileZilla or Total Commander everything works ok, but when i try wirh Gulp task i got strange error, i dont see the difference, here is my Gulp task and error message
gulp.task('ftp-test-connection', function () {
var conn = ftp.create({
host: 'hostname',
user: 'user',
password: 'password',
parallel: 10,
log: gutil.log
});
var globs = [
'./styles/**/*{css,png,jpg,gif,ttf,woff,eof,svg,woff2}',
'./images/**',
'./views/**',
'./scripts/vendor.scripts.min.js',
'./dist/index.html',
'./dist_test/main.scripts.min.js',
'./dist_test/web.config'
];
return gulp.src(globs, { base: '.', buffer: false })
.pipe(gulpIf('dist/index.html', rename({ dirname: '' })))
.pipe(gulpIf('dist/web.config', rename({ dirname: '' })))
.pipe(gulpIf('dist_test/main.scripts.min.js', rename({ dirname: '/scripts' })))
.pipe(conn.newer('/site/wwwroot'))
.pipe(conn.dest('/site/wwwroot'));
});
And here is my error
**
[11:31:59] ERROR Error: User cannot log in.
at makeError (C:\node_modules\vinyl-ftp\node_modules\ftp\lib\connection.js:1067:13)
at Parser.<anonymous> (C:\node_modules\vinyl-ftp\node_modules\ftp\lib\connection.js:113:25)
at emitTwo (events.js:87:13)
at Parser.emit (events.js:172:7)
at Parser._write (C:\node_modules\vinyl-ftp\node_modules\ftp\lib\parser.js:59:10)
at doWrite (_stream_writable.js:292:12)
at writeOrBuffer (_stream_writable.js:278:5)
at Parser.Writable.write (_stream_writable.js:207:11)
at Socket.ondata (C:\node_modules\vinyl-ftp\node_modules\ftp\lib\connection.js:273:20)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at Socket.Readable.push (_stream_readable.js:110:10)
at TCP.onread (net.js:523:20) (530)
Process terminated with code 1.
**

I faced the same issue with "vinyl-gulp" and Azure App Services (a.k.a. Azure Web Sites).
In my case the problem was caused by the "\" character contained on the Azure FTP username.
I just had to double the "\" (ex: "someuser\$someuser") to solve the issue.
I hope it helps...
M.

Related

Express app getting disconnected right after the connection

I created a rest api with Express. on my server.js the i have my mysql connection.. though the connection is made at first. It's working on my local machine properly but when i deployed on AWS EC2 service then i am facing this problem..
server.js
var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'localhost',
user: 'myusername',
password: 'mypassword',
database: 'mydatabasename'
});
connection.connect(function (err) {
if (err) throw err;
console.log('connected!');
});
module.exports = connection;
i tried pm 2 handledisconnect() following other project function none worked.getting following error...
restapi#0.0.0 start /home/bcs_quiz_console/bcs-preparation-backend/restapi
npm start
connected!
events.js:180
throw er; // Unhandled 'error' event
^
Error: Connection lost: The server closed the connection.
at Protocol.end (/home/bcs_quiz_console/bcs-preparation-backend/restapi/node_modules/mysql/lib/protocol/Protocol.js:112:13)
at Socket. (/home/bcs_quiz_console/bcs-preparation-backend/restapi/node_modules/mysql/lib/Connection.js:97:28)
at Socket. (/home/bcs_quiz_console/bcs-preparation-backend/restapi/node_modules/mysql/lib/Connection.js:525:10)
at Socket.emit (events.js:208:15)
at endReadableNT (_stream_readable.js:1168:12)
at processTicksAndRejections (internal/process/task_queues.js:77:11)
Emitted 'error' event at:
at Connection._handleProtocolError (/home/bcs_quiz_console/bcs-preparation-backend/restapi/node_modules/mysql/lib/Connection.js:426:8)
at Protocol.emit (events.js:203:13)
at Protocol._delegateError (/home/bcs_quiz_console/bcs-preparation-backend/restapi/node_modules/mysql/lib/protocol/Protocol.js:398:10)
at Protocol.end (/home/bcs_quiz_console/bcs-preparation-backend/restapi/node_modules/mysql/lib/protocol/Protocol.js:116:8)
at Socket. (/home/bcs_quiz_console/bcs-preparation-backend/restapi/node_modules/mysql/lib/Connection.js:97:28)
[... lines matching original stack trace ...]
at processTicksAndRejections (internal/process/task_queues.js:77:11) {
fatal: true,
code: 'PROTOCOL_CONNECTION_LOST'
}
Thank anyone who can help in advance..

what is 'node:6856' warnig?

This error came up when I tried running server. what should I do?
(node:6856) DeprecationWarning: current URL string parser is
deprecated, and will be removed in a future version. To use the new
parser, pass option { useNewUrlParser: true } to MongoClient.connect.
Server running on port ${port} { MongoNetworkError: failed to connect
to server [ds263172.mlab.com:63172] on first connect
[MongoNetworkError: connect ETIMEDOUT 54.171.245.223:63172] at
Pool. (D:\Learning &
Interest\Computer\Web\projects\devconnector\node_modules\mongodb-core\lib\topologies\server.js:564:11)
at emitOne (events.js:116:13) at Pool.emit (events.js:211:7) at
Connection. (D:\Learning &
Interest\Computer\Web\projects\devconnector\node_modules\mongodb-core\lib\connection\pool.js:317:12)
at Object.onceWrapper (events.js:317:30) at emitTwo (events.js:126:13)
at Connection.emit (events.js:214:7) at Socket.
(D:\Learning &
Interest\Computer\Web\projects\devconnector\node_modules\mongodb-core\lib\connection\connection.js:246:50)
at Object.onceWrapper (events.js:315:30) at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7) at emitErrorNT
(internal/streams/destroy.js:66:8) at _combinedTickCallback
(internal/process/next_tick.js:139:11) at process._tickCallback
(internal/process/next_tick.js:181:9) name: 'MongoNetworkError',
errorLabels: [ 'TransientTransactionError' ],
[Symbol(mongoErrorContextSymbol)]: {} }
On your MongoClient.connect(...) statement add {useNewParser: true}. Your connect statement should look something like this:
MongoClient.connect("mongodb://localhost:27017/YourDB", { useNewUrlParser: true })
As the warning suggests you need to use the updated URL parser
USE this for Reference

Unknown column "something" in `Field list`, What's wrong?

I'm writing a server at port 3000 and its job is to get the data from "Signup.ejs" input's values and then inserting them into the database.
All is fine but there's a problem, it says to me that TechnoBoy is an unknown column in Field list
I tried inserting "" or even `` around ${} but it didn't work well since a new error has appeared.
This is my Connection.js file that I use it to create a connection and then export it to connect it in my app's files:
let mysql = require("mysql");
let connection = mysql.createConnection({
host: "localhost",
user: "root",
password: "something",
database: "test"
});
module.exports = connection;
And this is my Server.js that I use it to create a server and connect to the database insert the data into it:
let connection = require("./Connection.js");
let bodyParser = require("body-parser");
let express = require("express");
let app = express();
let urlencodedParser = bodyParser.urlencoded({ extended: false });
app.listen(3000, function() {
console.log("The server at port 3000 is open!");
});
app.set("view engine", "ejs");
app.get("/Signup", (req, res) => {
res.render("Register");
});
connection.connect();
app.post("/Signup", urlencodedParser, function(req, res) {
console.log(req.body);
res.render("Register");
connection.query(
`insert into users (Username, User_Password) values (${
req.body.Username
}, ${req.body.Password})`
);
});
Error I receive when I insert some data into input fields:
Error: ER_BAD_FIELD_ERROR: Unknown column 'TechnoBoy' in 'field list'
at Query.Sequence._packetToError (C:\Users\ha\node_modules\mysql\lib\protocol\sequences\Sequence.js:47:14)
at Query.ErrorPacket (C:\Users\ha\node_modules\mysql\lib\protocol\sequences\Query.js:77:18)
at Protocol._parsePacket (C:\Users\ha\node_modules\mysql\lib\protocol\Protocol.js:278:23)
at Parser.write (C:\Users\ha\node_modules\mysql\lib\protocol\Parser.js:76:12)
at Protocol.write (C:\Users\ha\node_modules\mysql\lib\protocol\Protocol.js:38:16)
at Socket.<anonymous> (C:\Users\ha\node_modules\mysql\lib\Connection.js:91:28)
at Socket.<anonymous> (C:\Users\ha\node_modules\mysql\lib\Connection.js:502:10)
at Socket.emit (events.js:182:13)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
--------------------
at Protocol._enqueue (C:\Users\ha\node_modules\mysql\lib\protocol\Protocol.js:144:48)
at Connection.query (C:\Users\ha\node_modules\mysql\lib\Connection.js:200:25)
at C:\Users\ha\OneDrive\Images\Documents\Projects\UI-Server\Server.js:17:14
at Layer.handle [as handle_request] (C:\Users\ha\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\ha\node_modules\express\lib\router\route.js:137:13)
at C:\Users\ha\node_modules\body-parser\lib\read.js:130:5
at invokeCallback (C:\Users\ha\node_modules\raw-body\index.js:224:16)
at done (C:\Users\ha\node_modules\raw-body\index.js:213:7)
at IncomingMessage.onEnd (C:\Users\ha\node_modules\raw-body\index.js:273:7)
at IncomingMessage.emit (events.js:182:13)
Emitted 'error' event at:
at Connection._handleProtocolError (C:\Users\ha\node_modules\mysql\lib\Connection.js:425:8)
at Protocol.emit (events.js:182:13)
at Protocol._delegateError (C:\Users\ha\node_modules\mysql\lib\protocol\Protocol.js:390:10)
at Query.<anonymous> (C:\Users\ha\node_modules\mysql\lib\protocol\Protocol.js:153:12)
at Query.emit (events.js:182:13)
at Query.Sequence.end (C:\Users\ha\node_modules\mysql\lib\protocol\sequences\Sequence.js:78:12)
at Query.ErrorPacket (C:\Users\ha\node_modules\mysql\lib\protocol\sequences\Query.js:90:8)
at Protocol._parsePacket (C:\Users\ha\node_modules\mysql\lib\protocol\Protocol.js:278:23)
at Parser.write (C:\Users\ha\node_modules\mysql\lib\protocol\Parser.js:76:12)
at Protocol.write (C:\Users\ha\node_modules\mysql\lib\protocol\Protocol.js:38:16)
The query I used(which is in connection.query btw):
insert into users (Username, User_Password) values (${
req.body.Username
}, ${req.body.Password})
Excuse me if this is a stupid question or something, I'm very new to backend and this one is my first try on it.
I'm an idiot. I configured Password field to be int so it can't enter strings but I passed it a string, that's why when I was passing it, it was saying wrong syntax and stuff.
Oh and also, I forgot to wrap the username with "" although I still don't know how it is a problem when the property is a string itself.
Problem got solved, it can be closed now.

Sails JS installation and database connection error

I am new to sails.js and i am trying to make it work but unable to install it properly.
During installation, first it was giving MSB4132 issue
then i installed visual studio 2010 to resolve that issue but then is starts showing around 2 pages of red text error.
due to this issue sails new project is working fine but when i am trying to connect it to my sql then it is showing issue.
changes i made for connecting to mysql
In SailsTest/config/connection.js
TestServer: {
adapter: 'sails-mysql',
host: 'localhost',
user: 'root',
password: '',
port: 4343,
database: 'sailstest'
},
In SailsTest/config/model.js
connection: 'TestServer',
migrate: 'safe'
In SailsTest/api/controller/userController.js
module.exports = {
get:function(req, res){
User.find()
.exec(function(err, users){
if(err){
console.log(err);
return res.json(err);
}
return res.json(users);
})
}
};
In SailsTest/config/route.js
'/': {
view: 'homepage'
},
'/user/get':'UserController.get'
after all this on
http://localhost:1337/user/get it is showing following error
{
"error": "E_UNKNOWN",
"status": 500,
"summary": "Encountered an unexpected error",
"raw": {}
}
this is the error log coming.
Error (E_UNKNOWN) :: Encountered an unexpected error
: Could not connect to MySQL:
Error: connect ECONNREFUSED 127.0.0.1:4343
at afterwards (C:\Users\Ashish\Desktop\SailsTest\node_modules\sails-mysql\lib\connections\spawn.js:72:13)
at C:\Users\Ashish\Desktop\SailsTest\node_modules\sails-mysql\lib\connections\spawn.js:40:7
at Handshake.onConnect (C:\Users\Ashish\Desktop\SailsTest\node_modules\mysql\lib\Pool.js:54:9)
at Handshake.Sequence.end (C:\Users\Ashish\Desktop\SailsTest\node_modules\mysql\lib\protocol\sequences\Sequence.js:96:24)
at Protocol.handleNetworkError (C:\Users\Ashish\Desktop\SailsTest\node_modules\mysql\lib\protocol\Protocol.js:358:14)
at PoolConnection.Connection._handleNetworkError (C:\Users\Ashish\Desktop\SailsTest\node_modules\mysql\lib\Connection.js:382:18)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at emitErrorNT (net.js:1256:8)
at nextTickCallbackWith2Args (node.js:455:9)
at process._tickDomainCallback (node.js:410:17)

sails-mysql: ER_NO_DB_ERROR: No database selected

When trying to use sails-mysql I get an ER_NO_DB_ERROR: No database selected exception.
Even though I followed all the instructions I was able to find as closely as possible. I also looked into related issues:
Sailsjs - How to use mySQL
https://github.com/balderdashy/sails/issues/632
http://dustinbolton.com/error-er_no_db_error-no-database-selected/
Nothing seemed to help so far.
This is what I am doing:
I started out with a fresh project:
sails new sql-test
cd sql-test
Installed sails-mysql
sudo npm install sails-mysql
I changed the config:
// config/adapters.js
module.exports.adapters = {
'default': 'mysql',
mysql: {
module : 'sails-mysql',
host : 'localhost',
port : 3306,
user : 'root',
password : 'superSecret',
database : 'testDB'
}
};
Created a Model:
// api/models/User.js
module.exports = {
attributes: {
name: 'string'
}
};
And when I try to run it from the project's root:
sails lift
I get the following:
Logic error in mySQL ORM.
{ [Error: ER_NO_DB_ERROR: No database selected] code: 'ER_NO_DB_ERROR', index: 0 }
error: Hook failed to load: orm (Error: ER_NO_DB_ERROR: No database selected)
error: Error encountered while loading Sails core!
error: Error: ER_NO_DB_ERROR: No database selected
at Query.Sequence._packetToError (/home/tster/Documents/sandbox/sql-test/node_modules/sails-mysql/node_modules/mysql/lib/protocol/sequences/Sequence.js:32:14)
at Query.ErrorPacket (/home/tster/Documents/sandbox/sql-test/node_modules/sails-mysql/node_modules/mysql/lib/protocol/sequences/Query.js:82:18)
at Protocol._parsePacket (/home/tster/Documents/sandbox/sql-test/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Protocol.js:172:24)
at Parser.write (/home/tster/Documents/sandbox/sql-test/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Parser.js:62:12)
at Protocol.write (/home/tster/Documents/sandbox/sql-test/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Protocol.js:37:16)
at Socket.ondata (stream.js:51:26)
at Socket.EventEmitter.emit (events.js:117:20)
at Socket.<anonymous> (_stream_readable.js:746:14)
at Socket.EventEmitter.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
at readableAddChunk (_stream_readable.js:165:9)
at Socket.Readable.push (_stream_readable.js:127:10)
at TCP.onread (net.js:526:21)
--------------------
at Query.Sequence (/home/tster/Documents/sandbox/sql-test/node_modules/sails-mysql/node_modules/mysql/lib/protocol/sequences/Sequence.js:15:20)
at new Query (/home/tster/Documents/sandbox/sql-test/node_modules/sails-mysql/node_modules/mysql/lib/protocol/sequences/Query.js:12:12)
at Function.Connection.createQuery (/home/tster/Documents/sandbox/sql-test/node_modules/sails-mysql/node_modules/mysql/lib/Connection.js:48:10)
at Connection.query (/home/tster/Documents/sandbox/sql-test/node_modules/sails-mysql/node_modules/mysql/lib/Connection.js:100:26)
at __DESCRIBE__ (/home/tster/Documents/sandbox/sql-test/node_modules/sails-mysql/lib/adapter.js:121:20)
at afterwards (/home/tster/Documents/sandbox/sql-test/node_modules/sails-mysql/lib/adapter.js:571:7)
at Handshake._callback (/home/tster/Documents/sandbox/sql-test/node_modules/sails-mysql/lib/adapter.js:549:9)
at Handshake.Sequence.end (/home/tster/Documents/sandbox/sql-test/node_modules/sails-mysql/node_modules/mysql/lib/protocol/sequences/Sequence.js:66:24)
at Handshake.Sequence.OkPacket (/home/tster/Documents/sandbox/sql-test/node_modules/sails-mysql/node_modules/mysql/lib/protocol/sequences/Sequence.js:75:8)
at Protocol._parsePacket (/home/tster/Documents/sandbox/sql-test/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Protocol.js:172:24)
at Parser.write (/home/tster/Documents/sandbox/sql-test/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Parser.js:62:12)
at Protocol.write (/home/tster/Documents/sandbox/sql-test/node_modules/sails-mysql/node_modules/mysql/lib/protocol/Protocol.js:37:16)
at Socket.ondata (stream.js:51:26)
at Socket.EventEmitter.emit (events.js:117:20)
at Socket.<anonymous> (_stream_readable.js:746:14)
at Socket.EventEmitter.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
at readableAddChunk (_stream_readable.js:165:9)
at Socket.Readable.push (_stream_readable.js:127:10)
at TCP.onread (net.js:526:21)
Additional Information:
sails v0.9.13
sails-mysql (v0.9.9)
mysql v14.14 Distrib 5.5.34, for debian-linux-gnu (x86_64) using readline 6.2
I can connect the the database via command line.
I am able to connect and query the Database when using node-mysql
Could anybody give me some advice? Am I missing something? Anything else I should check out?
I just hit this same problem. In order to get it to work, I had to add the adapter configuration information to my model, e.g. /api/models/User.js:
module.exports = {
adapter: 'mysql',
config: {
host: 'localhost',
user: 'user',
port:'3306',
// Psst.. You can put your password in config/local.js instead
// so you don't inadvertently push it up if you're using version control
password: 'secret',
database: 'sailstest'
},
attributes: {
firstName: 'STRING'
}
};
See the docs:
http://sailsjs.org/#!documentation/models
I also had to add /api/controllers/UserController.js manually, as the generate function did not add it on this app, although it did add it on the previous test app I made.
UPDATE:
Install the Sails.js beta to get better functionality.
npm install sails#beta -g
Not only does the config actually work as expected (under config/connections.js), the ORM features support associations, which are not supported in the 0.9 release.
I know this question already has an answer, but it's more of a workaround. This is what fixed the same issue for me.
Changing the default adapters.js file mysql adapter object from myLocalMySQLDatabase to simply mysql seemed to fix it for me.
Hope this helps.
You may get this error when the .env file is not in the same directory.
You can check what the error is with the following code:
const result = require('dotenv').config();
if (result.error) {
console.log(result.error)
}
console.log(result.parsed)
You must take care about data type.
if you have module like this
module.exports = {
attributes: {
name: 'string'
}
};
In database under modal name table field name must be varchar.
My database field is set to text and I getting this error , when change it to varchar everything work.