NetSuite SuiteScript 2.0 Integration with external hook - integration

I need to setup EPL2 label printing from Netsuite. Unfortunately the company this is for is very small and they don't have much money to spend, hence they cannot buy a $1000 label printing solution.
The current system uses a linux server that then sends a file to one of the CUPS print server queues using the linux cat command. From there it goes to a Intel NetportExpress 10/100 Print Server and then to the Argox V1000+ label printer. This is via a corporate network ip address.
Instead I started looking at some cheap options:
Popup a browser window with content type text/plain and use a suitelet to populate that browser window with the EPL2 label printer codes. Then open a print dialog window so that the user can print to the label printer driver. This requires installation of the label printer driver for all users. Sadly I could not get this to print a label.
Integration from Netsuite via a Restlet to an external python application (on Linux) that can then perform the linux cat command needed to print the label. The Restlet works nice, but unfortunately there does not seem to be a way to have some sort of hook that fires when a new label custom record arrives. Therefore I have to keep on polling the Restlet from Python every 2 seconds to see if a new label is waiting to be printed. I started running this about an hour ago and so far I have made about 2500 requests without errors. My concurrency limit is 5 and I'm using 2 so that seems ok. The script does very little so I don't think there will be size limit issues. The problem is just that I wonder whether NetSuite will eventually terminate my script for doing so many requests. Not sure whether there is such a governance issue, but can't imagine that they won't eventually stop that sort of thing.
Use the http module to send data in an ajax type manner. This should be able to pickup when new data arrives instead of having to poll (not sure). The problem with this is that I assume I will need a static IP address which is sadly an expensive option.
Use Netsuite SOAP web services which might have a hook instead of polling (not sure). I think this would not be free (like Restlets) either.
So my question is whether there is a better option that I'm missing or what would you recommend. Also would I hit some sort of governance limit if I poll every 2 seconds with option 2?
Update: The polling mysteriously stopped working after 7395 requests and about 3 hours. It did not return an error that I'm aware of. The rejected requests on Integration Governance shows 0.

I used to do the emailing thing quite a bit and it works pretty well. Volume may be an issue.
Another thing to do is just get a static IP address with something like ngrok.
ngrok runs on linux/mac/windows so you'd be able to write an app that listens on a particular port. Netsuite would send an https post to that app at (for instance) https://printing.mycompany.ngrok.io and the app would handle local printing.
I believe ngrok runs about $US60/year.
the app can verify identity with some sort of timestamp and hash so that if someone does get the https address they couldn't easily use all your paper or cause a DoS situation.

We got bamboozled by a printer vender (Zebra) before we found out that we could HTTP post to most printers using PRINTER_IP:9100 and just sending the RAW ZPL/EPL as the body.
Look into: IPP enabled printers. most are these days. saves you 1000's in longrun if you have a large warehouse operation like we do

Instead of polling I would have NetSuite initiate the connection in an afterSubmit User Event script.
I've automated label printing by having NetSuite email attachments to a dedicated mail box which is monitored by a Linux server. My setup is documented here:
https://gist.github.com/michoelchaikin/80af08856144d340b335d69aa383dbe7

Related

Banno OATH Cannot GET /v0/oidc/auth

Completely working Banno simple-plugin-example using one AWS Linux server with NodeJS copied to be transitioned to work under a Microsoft IIS server with NodeJS and URL Rewrites and all that entails basically worked out; but fails when it gets to actual process of OATH apparently as getting a "Cannot GET /v0/oidc/auth" response. Tried a number of ideas; but looking for some ideas to try.
I'm unable to reproduce the behavior that you saw, which makes me wonder if you ran into a temporary blip.
Assuming that we're talking about the latest version (commit c8775db2e3d9ecb4ce9ca708475d81d5936adf0e) of the Simple Plugin Example, then there are a few things to check and/or try.
It'll be good to check that the environment value in your config.js is correct. The config-EXAMPLE.js in the repo uses https://digital.garden-fi.com which matches up with the Garden demo financial institution. However, if you're not running this with a Client ID and Client Secret that's from Garden (i.e. this is with a different financial institution) then you'll have to change that environment value as appropriate for your financial institution.
It'll be good to double-check that the Client ID and Client Secret match up with your External Application which is configured for your plugin.
If you're running the Simple Plugin Example locally, then you can try navigating to the http://localhost:8080/dynamic URL which is expected by the plugin when the code is run locally. This is a good way to figure out if the sample code itself is running as expected.
Assuming the above is fine, it'll be good to double-check the "URL Rewrites" which you mentioned...it's unclear what those URL rewrites are doing, but it's possible that you have some code which is interfering with what the sample code is expecting.

Global Payments Hosted Payment Page Integration - sandbox and prod POSTs back to merchantUrl delays

I'm running our Hosted Payment Page integration the same as the official js lib:
https://github.com/globalpayments/rxp-js/blob/master/examples/hpp/process-a-payment-embedded-autoload-callback.html
All is good except this bit is very slow for the response to come back to our side with the approved/failed transaction:
https://github.com/globalpayments/rxp-js/blob/9909985b96ab5ed945614affad5f3739827f956b/examples/hpp/process-a-payment-embedded-autoload-callback.html#L16
e.g. The form gets presented, you enter your card details and click submit (on HPP) and then the 3D secure shows, does it's thing but around 4 mins later the result come back within the answer line (the above link, line 16). I'm not sure why it's so slow. Sandbox and Production are the same.
I'm opening a support case anyway, but if anyone has any ideas.
Thanks,
Gavin.
Was the firewall on the box blocking https / port 443 from the public. Obviously the libs do something. All was instant when off.

WebRTC video works locally but not remotely

There's quite a bit of code involved, so I threw what I had into a temporary github repo:
https://github.com/stevendesu/webrtc-failure
I'm learning WebRTC and long-term want to do some fancy stuff, but for now I'm starting simple: send a video from one computer to another. Unfortunately this failed. Here's what I've set up so far...
On a development server I own I installed coturn to act as a STUN/TURN server
I created two pages: broadcast.html and watch.html. The former creates a media stream and (using Socket.IO) sends the connection details to a signaling server. The latter gets the connection details from the signaling server and attempts to watch the stream
After running npm install you can npm start to run the server and access it at localhost:2017.
So here's what works:
After opening broadcast.html you are prompted for a broadcast ID. You can type anything here, but I usually just do an incrementing number - so I start with "1"
After entering a broadcast ID, and a short delay, you see your webcam feed on the screen. Looking at the console you can see several messages have been exchanged with the Socket.IO server
If you open watch.html in a new tab, you are prompted for a broadcast ID. Enter the same ID as before
After entering the ID, and a short delay, you will see your webcam feed on the new tab. Looking at the console you can see that the earlier ICE candidates and offer details were sent by the Socket.IO server and the watcher responded with an answer
Returning to the broadcast tab, you can verify that the answer was received and processed. A connection has now been established
For bonus points, the pc variable is in the global scope (PeerConnection) so in the console you can establish an RTCDataChannel and send messages between the tabs directly (bypassing the Socket.IO server)
Here's what doesn't work:
For now (and I know why this is, so it's not a concern) only the FIRST person to enter an ID into the watch.html page can actually see the broadcast. It's not "broadcast", it's just peer-to-peer, and once one connection has been established then future connections fail
My issue: if I open watch.html from a different computer or device (either on the same network or a different network) then the video never plays
In the latter case if you look at the console you'll see the offer and ice candidates are delivered to the watcher, the watcher generates an answer, the answer is sent back to the broadcaster, and the watcher sees a media stream added to the PeerConnection. This media stream is converted to a blob URL and assigned as the source of the video element.
I'm at a point where I don't know how to progress. I don't know why the video isn't showing up.
your watch.js does not emit ice candidates. That is one possible cause. If that doesn't help you can use chrome://webrtc-internals to figure out what is going on -- see here for a description of how to interpret what is going on.
You might also want to look into modernizing your code. https://webrtc.github.io/samples/src/content/peerconnection/pc1/ is a fairly simple example of modern WebRTC code using promises and other things like using srcObject instead of the deprecated URL.createObjectURL.

How do I read and write data to/from COM port in HTML pages?

Has anyone tried reading and writing data to/from COM ports in webpages. I am running Apache webserver. Could anyone one suggest me about what scripting should I use to access data in html pages from COM ports on the system ?
Thanks
There is currently no way to do this directly from HTML 5 (except perhaps for maybe on the blackberry tables OS or BB10 using webworks (would also be client side), but I have not personally tried this). If you are trying to read serial data on the server and showing the result in an HTML document it's quite easily done using javascript to sent post requests to your web-server. doing the work on the server and responding, and interpreting the server's response in the javascript.
There's lots of online guides for sending post requests from javascript asynchronously, for instance: JavaScript: Sending POST, redirecting to response.
On the server side, lots of options available. You can use PHP-serial to read serial data: http://code.google.com/p/php-serial/, or if it's not a PHP server there are libraries available for most languages. Or, if you don't like PHP-serial you can use your server language to call another executable/script on the system to do the serial reading (that external program can relay the read data via stdout or file output). Either way, the webserver can then respond to the HTTP request simply by printing out the data, and your client-side javascript can read the response body to retrieve that data.

Trigger a web page refresh

I am working on an android application that will show an html page that contains only some text on a tablet device. The device will be on and showing this page for long periods of time(several hours). The text on this page will get changed from time to time.
To change the text on the page I've made a separate second page that contains a form to enter the new strings into and a submit button that uses ASP to generate a new version of the first page and save it over top of the original copy. This is set up and working great, but it means that I have to refresh the page very frequently in order to ensure I am always showing the latest message.
I am looking for a way that I could trigger a refresh only when a new message is saved. That way I will not have to refresh the page every minute but the new message will still get shown in a timely manner.
No dice, HTTP is built as a stateless, pull-only (ignoring file uploads) protocol. The server can't push data to the client, the client has to actually poll the server for new information.
However, you can minimize the overhead of this by using an AJAX call with JSON as the transport protocol instead of generating entire web pages and update your page on the client side. The overhead should be minimal for almost any application.
If you were just a web-app, I would suggest looking into the various Comet frameworks.
http://www.google.com/search?q=comet+framework
But, since you have an Android shell around it, you can make a Socket connection back to your server and have the server signal when it's time to refresh. It's essentially the same, but you don't need to code up the push in JavaScript if you're more comfortable in Java.