Import javascript library
-
@phildunlap i hope that my explanation above made sense. Thanks.
-
The HTTP Retriever doesn't execute or interpret the content it retrieves. You would end up in the same boat as before, where coolprop runs Java out of memory in your instance. That's what this is an effort to circumvent, right?
I think what you're looking for is to have a node js running on a machine with sufficient memory that executes these calculations and sets the values back to Mango through the API.
It is certainly possible, though, that you can leave this page open on the other computer in a browser (something which is executing it). You can create an automatic login for the user and just leave that page open somewhere. It's not the most robust solution, but it should work.
-
@phildunlap I understand but are you 100% certain that this wont work? Im pretty sure it was updating the values before.
-
Are you saying when you had the page open in a browser?
I am certain the HTTP retriever is basically treating it as text content for regex parsing, yes. It doesn't treat it as a webpage and execute its content.
-
@phildunlap said in Import javascript library:
Are you saying when you had the page open in a browser?
I am certain the HTTP retriever is basically treating it as text content for regex parsing, yes. It doesn't treat it as a webpage and execute its content.
running the script through another browser is not an option. Any other ways you can think of? Thanks.
-
@phildunlap how about running the url through something like phantomjs from command prompt?
-
I don't have experience with phantomjs but it looks like it might work. It will at least execute the JavaScript. It should be the same idea as using node, right?
-
@phildunlap said in Import javascript library:
I don't have experience with phantomjs but it looks like it might work. It will at least execute the JavaScript. It should be the same idea as using node, right?
Well,i just tried phantom and it wont work as it does not have arm distribution. I will tried node.js see what happens.
-
@phildunlap now with Node.js i need to convert my html file that references java script inside to full javascript!
-
@phildunlap do we have any sample javascripts that cna be used in node.js that use mangoapi? like retrieving values by XID and setting values? Thanks.
-
Yeah you might be able to get what you're looking for from the tests we've implemented in node: https://github.com/infiniteautomation/node-mango-client
-
@phildunlap Thanks. I get this error when i try to run the example:
$node example.js
(node:24509) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: connect ECONNREFUSED 127.0.0.1:8443 -
You would have to point it at your running Mango instance and port. It's from this section of example.js:
const client = new MangoClient({ protocol: 'https', host: 'localhost', port: 8443, rejectUnauthorized: false });
-
@phildunlap said in Import javascript library:
You would have to point it at your running Mango instance and port. It's from this section of example.js:
const client = new MangoClient({ protocol: 'https', host: 'localhost', port: 8443, rejectUnauthorized: false });
Its running locally on the same box. shouldnt localhost be enough? Thanks
-
No. It is using the HTTP API which is over TCP/IP and all TCP/IP connections require an address and a port. Edit: yes localhost is the host if its the same machine (usually, localhost means 127.0.0.1 usually)
-
@phildunlap said in Import javascript library:
No. It is using the HTTP API which is over TCP/IP and all TCP/IP connections require an address and a port. Edit: yes localhost is the host if its the same machine (usually, localhost means 127.0.0.1 usually)
ok, so im on the same machine and tried the local ip of the machine and still the samething.
Unhandled promise rejection (rejection id: 1): Error: connect ECONNREFUSED 192.168.1.125:8443ami i missing something?
-
Mango is not running on port 8443?
-
@phildunlap said in Import javascript library:
Mango is not running on port 8443?
mmm, where can i check it?
-
It's the web.port property in your Mango/overrides/properties/env.properties file or Mango/classes/env.properties files as "web.port". Judging from your earlier port of the HTTP Retriever data source, it's 85, but i have no way of knowing. It's 8080 by default.
-
@phildunlap said in Import javascript library:
It's the web.port property in your Mango/overrides/properties/env.properties file or Mango/classes/env.properties files as "web.port". Judging from your earlier port of the HTTP Retriever data source, it's 85, but i have no way of knowing. It's 8080 by default.
ok, web.port=8080 but i still get the same error as before.
$node example.js
(node:7075) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: connect ECONNREFUSED 192.168.1.125:8080