node-opcua OPCUAClient.connect error: Invalid position - node.js

When connecting to an OPCUA Server using an endpoint (opc.tcp://{serverIP:port}/OPCUASserver), I am getting an error that I do not know how to interpret.
I create an OPCUAClient using:
let client = OPCUAClient.create(clientOptions);
Then call connect
try {
await client.connect(connection.endpoint);
} catch (err) {
console.log('opcuaClient: connection error: ', err);
Here is the log message that gets printed to console:
opcuaClient: connection error: Error: Invalid position : buf.length=0 pos =0
at readTag (/node_js/app/node_modules/node-opcua-crypto/dist/source/asn1.js:36:15)
at Object.split_der (/node_js/app/node_modules/node-opcua-crypto/dist/source/crypto_explore_certificate.js:569:47)
at OPCUAClientImpl.getCertificate (/node_js/app/node_modules/node-opcua-common/dist/opcua_secure_object.js:37:52)
at OPCUAClientImpl.<anonymous> (/node_js/app/node_modules/node-opcua-client/dist/verify.js:106:34)
at Generator.next (<anonymous>)
at /node_js/app/node_modules/node-opcua-client/dist/verify.js:8:71
at new Promise (<anonymous>)
at __awaiter (/node_js/app/node_modules/node-opcua-client/dist/verify.js:4:12)
at OPCUAClientImpl.performCertificateSanityCheck (/node_js/app/node_modules/node-opcua-client/dist/verify.js:104:12)
at OPCUAClientImpl.<anonymous> (/node_js/app/node_modules/node-opcua-client/dist/private/client_base_impl.js:569:62)
at Generator.next (<anonymous>)
at /node_js/app/node_modules/node-opcua-client/dist/private/client_base_impl.js:8:71
at new Promise (<anonymous>)
at __awaiter (/node_js/app/node_modules/node-opcua-client/dist/private/client_base_impl.js:4:12)
at /node_js/app/node_modules/node-opcua-client/dist/private/client_base_impl.js:566:122
at Object.<anonymous> (/node_js/app/node_modules/#ster5/global-mutex/dist/source/index.js:194:26)
I am not sure what this error means.
Thanks!

Related

I keep running into the same error after trying to run Node User routes

I keep getting an error in my express-promise-router
var wrapHandler = function (handler) {if ("function" !== typeof handler) { var type = Object.prototype.toString.call(handler); var msg = "Expected a callback function but got a " + type; throw new Error(msg); } var handleReturn = function (args) { // Find the next function from the arguments var next = args.slice(-1)[0];
`Error is as follows:-
node_modules/express-promise-router/lib/express-promise-router.js:10
throw new Error(msg);
^`
Error: Expected a callback function but got a [object Undefined]
at /Users/alfredbanda/jobplus-backend/node_modules/express-promise-router/lib/express-promise-router.js:104:16 at Array.map (<anonymous>) at instanceToWrap.<computed> [as post] (/Users/alfredbanda/jobplus-backend/node_modules/express-promise-router/lib/express-promise-router.js:103:32) at Object.<anonymous> (/Users/alfredbanda/jobplus-backend/src/routes/auth.routes.js:4:8) at Module._compile (node:internal/modules/cjs/loader:1239:14) at Module._extensions..js (node:internal/modules/cjs/loader:1293:10) at Module.load (node:internal/modules/cjs/loader:1096:32) at Module._load (node:internal/modules/cjs/loader:935:12) at Module.require (node:internal/modules/cjs/loader:1120:19)
Node.js v19.4.0
[nodemon] app crashed - waiting for file changes before starting...
I know there is a problem with the callback function being passed to the "express-promise-router" module. Specifically, the error message says that it expected a callback function, but instead got an object of type "Undefined". I checked the function call and ensured that the correct callback function is being passed as an argument but to no avail.

whatsapp web gadd called without an id attr (id)

I am getting error while executing following function in whatsapp web
Function:
const data = window.Store.Presence.find(chatId);
Error:
/home/sariful/Public/whatappApi/files/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221
throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
^
Error: Evaluation failed: Error: gadd called without an id attr (id)
at p.gadd (https://web.whatsapp.com/bootstrap_qr.a93ca7c63be0f2cdef56.js:71:532289)
at https://web.whatsapp.com/bootstrap_qr.a93ca7c63be0f2cdef56.js:71:653775
at Generator.next (<anonymous>)
at t (https://web.whatsapp.com/vendor1~bootstrap_qr.27ae36d14a5e15ff6df9.js:2:65356)
at s (https://web.whatsapp.com/vendor1~bootstrap_qr.27ae36d14a5e15ff6df9.js:2:65567)
at https://web.whatsapp.com/vendor1~bootstrap_qr.27ae36d14a5e15ff6df9.js:2:65626
at Y (https://web.whatsapp.com/bootstrap_qr.a93ca7c63be0f2cdef56.js:31:99298)
at new y (https://web.whatsapp.com/bootstrap_qr.a93ca7c63be0f2cdef56.js:31:91865)
at https://web.whatsapp.com/vendor1~bootstrap_qr.27ae36d14a5e15ff6df9.js:2:65507
at p._find (https://web.whatsapp.com/bootstrap_qr.a93ca7c63be0f2cdef56.js:71:653867)
at ExecutionContext._evaluateInternal (/home/sariful/Public/whatappApi/files/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async ExecutionContext.evaluate (/home/sariful/Public/whatappApi/files/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)

"Cannot read property 'charCodeAt" of undefined"

On the online JDL-studio, I create a JDL file without any errors. After importing it, I get an error "TypeError: cannot read property 'charCodeAt" of undefined". How to find out the cause?
Error running generator entities: TypeError: Cannot read property 'charCodeAt' of undefined
TypeError: Cannot read property 'charCodeAt' of undefined
at module.exports (/Users/me/Documents/workspace/myapp/node_modules/ret/lib/index.js:75:54)
at new RandExp (/Users/me/Documents/workspace/myapp/node_modules/randexp/lib/randexp.js:26:19)
at new RandexpWithFaker (/Users/me/Documents/workspace/myapp/node_modules/generator-jhipster/utils/faker.js:26:5)
at Faker.faker.createRandexp (/Users/me/Documents/workspace/myapp/node_modules/generator-jhipster/utils/faker.js:61:41)
at Object.field.createRandexp (/Users/me/Documents/workspace/myapp/node_modules/generator-jhipster/utils/field.js:360:37)
at generateFakeDataForField (/Users/me/Documents/workspace/myapp/node_modules/generator-jhipster/utils/field.js:101:29)
at Object.field.generateFakeData (/Users/me/Documents/workspace/myapp/node_modules/generator-jhipster/utils/field.js:365:16)
at /Users/me/Documents/workspace/myapp/node_modules/generator-jhipster/generators/database-changelog-liquibase/index.js:136:28
at Array.forEach (<anonymous>)
at module.exports.prepareFakeData (/Users/me/Documents/workspace/myapp/node_modules/generator-jhipster/generators/database-changelog-liquibase/index.js:120:18)
at Object.<anonymous> (/Users/me/Documents/workspace/myapp/node_modules/yeoman-generator/lib/index.js:1024:25)
at /Users/me/Documents/workspace/myapp/node_modules/run-async/index.js:49:25
at new Promise (<anonymous>)
at /Users/me/Documents/workspace/myapp/node_modules/run-async/index.js:26:19
at runLoop.add.once.once (/Users/me/Documents/workspace/myapp/node_modules/yeoman-generator/lib/index.js:1025:11)
at Immediate.<anonymous> (/Users/me/Documents/workspace/myapp/node_modules/grouped-queue/lib/subqueue.js:48:34)
ERROR! Cannot read property 'charCodeAt' of undefined
TypeError: Cannot read property 'charCodeAt' of undefined
at module.exports (/Users/me/Documents/workspace/myapp/node_modules/ret/lib/index.js:75:54)
at new RandExp (/Users/me/Documents/workspace/myapp/node_modules/randexp/lib/randexp.js:26:19)
at new RandexpWithFaker (/Users/me/Documents/workspace/myapp/node_modules/generator-jhipster/utils/faker.js:26:5)
at Faker.faker.createRandexp (/Users/me/Documents/workspace/myapp/node_modules/generator-jhipster/utils/faker.js:61:41)
at Object.field.createRandexp (/Users/me/Documents/workspace/myapp/node_modules/generator-jhipster/utils/field.js:360:37)
at generateFakeDataForField (/Users/me/Documents/workspace/myapp/node_modules/generator-jhipster/utils/field.js:101:29)
at Object.field.generateFakeData (/Users/me/Documents/workspace/myapp/node_modules/generator-jhipster/utils/field.js:365:16)
at /Users/me/Documents/workspace/myapp/node_modules/generator-jhipster/generators/database-changelog-liquibase/index.js:136:28
at Array.forEach (<anonymous>)
at module.exports.prepareFakeData (/Users/me/Documents/workspace/myapp/node_modules/generator-jhipster/generators/database-changelog-liquibase/index.js:120:18)
at Object.<anonymous> (/Users/me/Documents/workspace/myapp/node_modules/yeoman-generator/lib/index.js:1024:25)
at /Users/me/Documents/workspace/myapp/node_modules/run-async/index.js:49:25
at new Promise (<anonymous>)
at /Users/me/Documents/workspace/myapp/node_modules/run-async/index.js:26:19
at runLoop.add.once.once (/Users/me/Documents/workspace/myapp/node_modules/yeoman-generator/lib/index.js:1025:11)
at Immediate.<anonymous> (/Users/me/Documents/workspace/myapp/node_modules/grouped-queue/lib/subqueue.js:48:34)
I find that its cause is the following email pattern:
email String required minlength(6) maxlength(255) pattern(/^\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*$/) unique,
Now, a question would be what is the acceptable email pattern for JHipster.

jhipster:entity error in jhispter:client or server app

I created an app with jhipster:client and another one with :server and tried to generate an entity 'client only' in the client app but I'm getting:
'events.js:163
throw er; // Unhandled 'error' event
^
TypeError: Cannot read property 'endsWith' of undefined
at constructor.getAngularAppName (/Users/ndjordjevic/IdeaProjects/jh-client-jwt/node_modules/generator-jhipster/generators/generator-base.js:1604:65)
at constructor.getConfig (/Users/ndjordjevic/IdeaProjects/jh-client-jwt/node_modules/generator-jhipster/generators/entity/index.js:160:40)
at Object.<anonymous> (/Users/ndjordjevic/IdeaProjects/jh-client-jwt/node_modules/yeoman-generator/lib/index.js:417:23)
at /Users/ndjordjevic/IdeaProjects/jh-client-jwt/node_modules/run-async/index.js:25:25
at /Users/ndjordjevic/IdeaProjects/jh-client-jwt/node_modules/run-async/index.js:24:19
at /Users/ndjordjevic/IdeaProjects/jh-client-jwt/node_modules/yeoman-generator/lib/index.js:418:9
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)'
It works in 'server only' app.
Generating entities are only for 'full apps'?

Unhandled rejection TypeError when trying to promisify a node-mysql connection and query

I'm attempting to use bluebird's promisify with the node-mysql package. Node version is 4.2.4
var Promise = require('bluebird');
var mysqlClient = Promise.promisifyAll(require("mysql/lib/Connection").prototype);
Promise.promisifyAll(require("mysql/lib/Pool").prototype);
var connectionOptions = ({
host: 'localhost',
user: 'root',
password: '',
database: 'my_db'
});
var firstPost = "some sql here";
var results = [];
mysqlClient.connectAsync(connectionOptions).then(function(connection){
connection.query(firstPost, function(){
console.log('i reached line 26 of a node script. a minor miracle')
});
}).catch(function(err) {
console.log(err);
});
I get the error
[TypeError: Cannot read property 'socketPath' of undefined]
Stack trace:
Unhandled rejection TypeError: Cannot read property 'socketPath' of undefined
at Connection.connect (/vagrant/spam_smasher/node_modules/mysql/lib/Connection.js:87:32)
at Connection.tryCatcher (/vagrant/spam_smasher/node_modules/bluebird/js/release/util.js:11:23)
at Connection.ret [as connectAsync] (eval at <anonymous> (/vagrant/spam_smasher/node_modules/bluebird/js/release/promisify.js:184:12), <anonymous>:13:39)
at Object.<anonymous> (/vagrant/spam_smasher/bluebird.js:24:13)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
at node.js:963:3
Why am I getting this error and/or how could I debug it further? I tried to remote debug it but am not sure what I'm looking at when I get a few steps down the prototype chain. The Async functions do appear to be attached to the MysqlClient object.
Remore debugging reveals that the following section in node-mysql's Connection.js file is throwing the error :
if (!this._connectCalled) {
this._connectCalled = true;
// Connect either via a UNIX domain socket or a TCP socket.
this._socket = (this.config.socketPath)
? Net.createConnection(this.config.socketPath)
: Net.createConnection(this.config.port, this.config.host);
socketpath is not something you need to define when using node-mysql directly
It seems the Bluebird docs are out of date. They miss that you also need ConnectionConfig to be available and so this was missing in my code, causing the error.
I chose to abandon this problem to preserve my sanity. There is further discussion here and you may also want to check out mysql-promise

Resources