mikeobrien / node-sqlcmd-runner

Node.js wrapper for sqlcmd.
MIT License
6 stars 4 forks source link

sqlcmd-runner break my server, why? #4

Open aebrs opened 1 year ago

aebrs commented 1 year ago

I run this code on local machine and it works well: `var sqlcmd = require('sqlcmd-runner'); const path = require('path'); exports.executeFile = (dastur, year, cb) => { const file_func = path.join(__dirname, '../../../../Scripts/001/functions.sql') sqlcmd({ username: year.rows[0][1], password: year.rows[0][2], server: year.rows[0][3], database: year.rows[0][4], port: 1433, sql_cmd

    options: {
       instanceNAME:'SQLEXPRESS06',
       rowCollectionOnRequestCompletion: false,
       encrypt: false,
       enableArithAbort: true
   },
    inputFiles: [`${file_func}`]
})
.catch(function(error) { 
    cb(error.message)
})
.done(function() { 
    cb(null, 'درخواست بدون مشکل انجام شد')
});

}`

But when I run the same code on server it reset my back end and show errors: Access to XMLHttpRequest at 'http://app.mysite.ir/socket.io/?token=DFF54CD2-299D-4BC5-992D-6AD08D8CC236&EIO=4&transport=polling&t=OgiB4Hh&sid=C9hfs-E8majWlYZ7AAAA' from origin 'http://admin.mysite.ir' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. index.bceaf43a.js:15 GET http://app.mysite.ir/socket.io/?token=DFF54CD2-299D-4BC5-992D-6AD08D8CC236&EIO=4&transport=polling&t=OgiB4Hh&sid=C9hfs-E8majWlYZ7AAAA net::ERR_FAILED 200 (OK) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 doOpen @ index.bceaf43a.js:15 open @ index.bceaf43a.js:15 open @ index.bceaf43a.js:15 sn @ index.bceaf43a.js:15 open @ index.bceaf43a.js:15 (anonymous) @ index.bceaf43a.js:15 setTimeout (async) reconnect @ index.bceaf43a.js:15 onclose @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onClose @ index.bceaf43a.js:15 onError @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onError @ index.bceaf43a.js:15 (anonymous) @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onError @ index.bceaf43a.js:15 (anonymous) @ index.bceaf43a.js:15 setTimeout (async) n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 doOpen @ index.bceaf43a.js:15 open @ index.bceaf43a.js:15 open @ index.bceaf43a.js:15 sn @ index.bceaf43a.js:15 open @ index.bceaf43a.js:15 connect @ index.bceaf43a.js:15 open @ index.bceaf43a.js:15 (anonymous) @ index.bceaf43a.js:15 (anonymous) @ index.bceaf43a.js:5 Je.commit @ index.bceaf43a.js:5 Je.commit @ index.bceaf43a.js:5 (anonymous) @ index.bceaf43a.js:15 Promise.then (async) signUserIn @ index.bceaf43a.js:15 (anonymous) @ index.bceaf43a.js:5 Je.dispatch @ index.bceaf43a.js:5 Je.dispatch @ index.bceaf43a.js:5 i @ index.bceaf43a.js:15 (anonymous) @ index.bceaf43a.js:1 ln @ index.bceaf43a.js:1 ut @ index.bceaf43a.js:1 n @ index.bceaf43a.js:1 index.bceaf43a.js:15 POST http://app.mysite.ir/socket.io/?token=DFF54CD2-299D-4BC5-992D-6AD08D8CC236&EIO=4&transport=polling&t=OgiB8GI&sid=C9hfs-E8majWlYZ7AAAA 400 (Bad Request) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doWrite @ index.bceaf43a.js:15 (anonymous) @ index.bceaf43a.js:15 (anonymous) @ index.bceaf43a.js:15 Nd @ index.bceaf43a.js:15 (anonymous) @ index.bceaf43a.js:15 W_ @ index.bceaf43a.js:15 write @ index.bceaf43a.js:15 t @ index.bceaf43a.js:15 doClose @ index.bceaf43a.js:15 close @ index.bceaf43a.js:15 onClose @ index.bceaf43a.js:15 onError @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onError @ index.bceaf43a.js:15 (anonymous) @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onError @ index.bceaf43a.js:15 (anonymous) @ index.bceaf43a.js:15 setTimeout (async) n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 doOpen @ index.bceaf43a.js:15 open @ index.bceaf43a.js:15 open @ index.bceaf43a.js:15 sn @ index.bceaf43a.js:15 open @ index.bceaf43a.js:15 (anonymous) @ index.bceaf43a.js:15 setTimeout (async) reconnect @ index.bceaf43a.js:15 onclose @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onClose @ index.bceaf43a.js:15 onError @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onError @ index.bceaf43a.js:15 (anonymous) @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onError @ index.bceaf43a.js:15 (anonymous) @ index.bceaf43a.js:15 setTimeout (async) n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 onData @ index.bceaf43a.js:15 Ne.emit @ index.bceaf43a.js:15 onLoad @ index.bceaf43a.js:15 n.onreadystatechange @ index.bceaf43a.js:15 XMLHttpRequest.send (async) create @ index.bceaf43a.js:15 It @ index.bceaf43a.js:15 request @ index.bceaf43a.js:15 doPoll @ index.bceaf43a.js:15 poll @ index.bceaf43a.js:15 doOpen @ index.bceaf43a.js:15 open @ index.bceaf43a.js:15 open @ index.bceaf43a.js:15 sn @ index.bceaf43a.js:15 open @ index.bceaf43a.js:15 connect @ index.bceaf43a.js:15 open @ index.bceaf43a.js:15 (anonymous) @ index.bceaf43a.js:15 (anonymous) @ index.bceaf43a.js:5 Je.commit @ index.bceaf43a.js:5 Je.commit @ index.bceaf43a.js:5 (anonymous) @ index.bceaf43a.js:15 Promise.then (async) signUserIn @ index.bceaf43a.js:15 (anonymous) @ index.bceaf43a.js:5 Je.dispatch @ index.bceaf43a.js:5 Je.dispatch @ index.bceaf43a.js:5 i @ index.bceaf43a.js:15 (anonymous) @ index.bceaf43a.js:1 ln @ index.bceaf43a.js:1 ut @ index.bceaf43a.js:1 n @ index.bceaf43a.js:1 index.bceaf43a.js:15 WebSocket connection to 'ws://app.mysite.ir/socket.io/?token=DFF54CD2-299D-4BC5-992D-6AD08D8CC236&EIO=4&transport=websocket&sid=WbaLfqcZW3Hjh1uJAAAA' failed:

kujotx commented 1 year ago

Hi @aebrs,

It looks like the server where you code is executing has to receives an XML request that violates CORS.

sqlcmd-runner does not have anything to do with the error from that incoming request; sqlcmd-runner is not the reason for that error.

I suggest looking at where your application starts up to configure your CORS policy to accept that request from http://admin.mysite.ir.

Again, it is not sqlcmd-runner, but your application that is causing this issue.

Hope I helped you fix your issue!

aebrs commented 1 year ago

Hi @kujotx My last server was windows, shares Plesk, so there was many limitations, so I started my own ubuntu server now. Now I checked this code on my local machine with windows 10, it work fine. But in Ubuntu server it stop working too.

Using this code I try to execute a 'mssql' script to create 'schemas+funcs', 'tables', and 'sps', in order. `var sqlcmd = require('sqlcmd-runner'); const path = require('path');

exports.executeFile = (year, _file_data, _fileErr, cb) => { const fileErr = path.join(__dirname, '../../../../Scripts/001/tables_result_1402.sql') const file_func = path.join(__dirname, '../../../../Scripts/001/functions.sql') sqlcmd({ username: 'sa', password: 'Roshan1402Roshan', server: 'SQL_Latin1_General_CP1_CI_AS', database: 'ebrahimi_522_1402', port: 1433, options: { instanceNAME:'SQLEXPRESS06', rowCollectionOnRequestCompletion: false, encrypt: false, enableArithAbort: true }, inputFiles: [${file_func}], outputFile: ${fileErr}, }) .catch(function(error) { cb(error.message) }) .done(function() { cb(null, 'درخواست بدون مشکل انجام شد') }); }`

here is the error that I catched using PM2. monit: sqlcmd -S SQL_Latin1_General_CP1_CI_AS -d ebrahimi_522_1402 -U sa -P Error: spawn sqlcmd ENOENT at ChildProcess._handle.onexit (node:internal/child_process:283:19) at onErrorNT (node:internal/child_process:476:16) at process.processTicksAndRejections (node:internal/process/task_queues: errno: -2, code: 'ENOENT', syscall: 'spawn sqlcmd', path: 'sqlcmd', spawnargs: [ '-S', 'SQL_Latin1_General_CP1_CI_AS', '-d', 'ebrahimi_522_1402', '-U', 'sa', '-P', 'Roshan1402Roshan', '-i', '\\var\\www\\mysite\\app.mysite.ir\\Scripts\\001\\functions.sq '-o', '\\var\\www\\mysite\\app.mysite.ir\\Scripts\\001\\tables_resul ] } Started listening at: 8000

Script file contains code like this (not a long script): ... DROP SCHEMA IF EXISTS [fund] GO /****** Object: Schema [cost] Script Date: 1402/06/27 04:41:13 عـصـر ******/ DROP SCHEMA IF EXISTS [cost] GO /****** Object: Schema [app] Script Date: 1402/06/27 04:41:13 عـصـر ******/ DROP SCHEMA IF EXISTS [app] GO /****** Object: Schema [admin] Script Date: 1402/06/27 04:41:13 عـصـر ******/ DROP SCHEMA IF EXISTS [admin] GO /****** Object: Schema [acc] Script Date: 1402/06/27 04:41:13 عـصـر ******/ DROP SCHEMA IF EXISTS [acc] GO /****** Object: Schema [acc] Script Date: 1402/06/27 04:41:13 عـصـر ******/ CREATE SCHEMA [acc] GO /****** Object: Schema [admin] Script Date: 1402/06/27 04:41:13 عـصـر ******/ CREATE SCHEMA [admin] GO /****** Object: Schema [app] Script Date: 1402/06/27 04:41:13 عـصـر ******/ CREATE SCHEMA [app] GO /****** Object: Schema [cost] Script Date: 1402/06/27 04:41:13 عـصـر ******/ CREATE SCHEMA [cost] GO /****** Object: Schema [fund] Script Date: 1402/06/27 04:41:13 عـصـر ******/ CREATE SCHEMA [fund] GO /****** Object: Schema [report] Script Date: 1402/06/27 04:41:13 عـصـر ******/ CREATE SCHEMA [report] GO /****** Object: Schema [Store] Script Date: 1402/06/27 04:41:13 عـصـر ******/ CREATE SCHEMA [Store] GO /****** Object: Schema [trade] Script Date: 1402/06/27 04:41:13 عـصـر ******/ CREATE SCHEMA [trade] GO ...

I checked my server it has 8 GB memory, 4 GB as Swap: total used free shared buff/cache available Mem: 6.7Gi 1.7Gi 1.5Gi 1.5Mi 3.8Gi 5.0Gi Swap: 4.0Gi 0B 4.0Gi Do you have any idea?

aebrs commented 1 year ago

I found out some more about how it works. I installed sqlcmd in Ubuntu, now the os do some command like this: sqlcmd -S localhost -U sa -P My123Password -C then I can script like this: select 1 as Id GO and it works. So I changed my test code as follow: var sqlcmd = require('sqlcmd-runner'); const path = require('path'); exports.executeFile = (year, _file_data, _fileErr, cb) => { sqlcmd({ username: 'sa', password: 'Roshan1402Roshan', server: 'localhost\SQLEXPRESS,1433', database: 'ebrahimi_522_1402', trustServerCert: true, query: 'select 12 as Id' }) .catch((error) => { cb(error.message) }) .done((data) => { cb(null, data) }); } Output is changed but error not gone: sqlcmd -S localhost\SQLEXPRESS,1433 -d ebrahimi_522_1402 -U sa -P Roshan1402Ros Error: spawn sqlcmd ENOENT at ChildProcess._handle.onexit (node:internal/child_process:283:19) at onErrorNT (node:internal/child_process:476:16) at process.processTicksAndRejections (node:internal/process/task_queues:82: errno: -2, code: 'ENOENT', syscall: 'spawn sqlcmd', path: 'sqlcmd', spawnargs: [ '-S', 'localhost\SQLEXPRESS,1433', '-d', 'ebrahimi_522_1402',
'-U', 'sa', '-P', 'Roshan1402Roshan', '-C', '-Q', 'select 12 as Id' ] Code restarted: Started listening at: 8000

aebrs commented 1 year ago

sqlcmd

aebrs commented 1 year ago

Hi @aebrs,

It looks like the server where you code is executing has to receives an XML request that violates CORS.

sqlcmd-runner does not have anything to do with the error from that incoming request; sqlcmd-runner is not the reason for that error.

I suggest looking at where your application starts up to configure your CORS policy to accept that request from http://admin.mysite.ir.

Again, it is not sqlcmd-runner, but your application that is causing this issue.

Hope I helped you fix your issue!

Now I am certain that this component can not be applied to usual cloud servers, despite having minimal properties to run sqlcmdand some other properties that yet I don't know and is part of my current problem. Any how to run sqlcmdin a local machine dos not mean it will run on server, not at all.

aebrs commented 1 year ago

Hi @aebrs,

It looks like the server where you code is executing has to receives an XML request that violates CORS.

sqlcmd-runner does not have anything to do with the error from that incoming request; sqlcmd-runner is not the reason for that error.

I suggest looking at where your application starts up to configure your CORS policy to accept that request from http://admin.mysite.ir.

Again, it is not sqlcmd-runner, but your application that is causing this issue.

Hope I helped you fix your issue!

Sorry but No: it is not about CORS nor XML, opposite, running sqlcmdcode cause cloud server application to crash. As I monitored using pm2.monit the node.js application stop working and restart by pm2. I tested this code on both windows shared cloud server that restarted server and CORSplus XMLerrors come from this truth, again I changed my server and used UBUNTUand exactly monitoring application I found that the app.js stops and re-starts later by pm2. As I have found out sqlcmdneed to have some initials pre-installed properties on any OS to run properly, while in windows and developing environment, since we installed Microsoft SQL Express and SQL Manager and SQL tool kits, those properties are met, so sqlcmd-runner execute properly, but on a cloud server that minimally prepared, those requirements are not met.