JSPrintManager
JSPrintManager copied to clipboard
WebSocket connection to 'wss://localhost:25443/' failed:
Hi,
I'm seeking a solution for our specific use case. This script is implemented in a warehouse where employees use scanners and printers. Access to this particular interface is granted to warehouse personnel, but it's also accessible to office staff who do not have scanners or printers. We've encountered an issue where this script throws an exception repeatedly in the console, indicating a failure to connect to the websocket when office personnel access this interface. This occurs because they lack printers and scanners. We want to initiate this script only when scanners or printers are available.
The issue originates from the .start() method, which generates this error in the console. Is there a way to prevent this?
That specific machine where the error happens... does it have the JSPrintManager app Version 5.0 installed? Because the script is trying to connect to Version 5 of the app so if the user has installed any other version, then that could be the cause of the issue.
No, that machine is the computer of a manager who works in the office, and JSPrintManager is not installed on their system. I need to prevent this error from occurring if JSPrintManager is not installed. Is there a method to check for its availability?
If the app v5 is not installed then that error will be thrown. What you can do is to prevent it from being thrown more than once by using this setting in your website code JSPM.JSPrintManager.auto_reconnect = false;
And to know whether v5 app is installed or not then you should use this https://www.neodynamic.com/Products/Help/JSPrintManager5.0/articles/jsprintmanager.html#detecting-jspm-client-app
I am getting same error, with version 6. I am trying to handle a case where user does not have JSPM installed and I would like to show an instruction/error page. Although I wrapped my code in try/catch statement, I am still getting 'uncaught' error. What is the best way to prevent this, if any? If I set auto reconnect to false, it happens only once, but it still does happen.
@denisjovic we have still that issue also. :/
I had the same problem, and I fixed it by downloading the latest version of the JSPrintManager.js file
I would also like to know what else could be done. Like maybe to render a modal with instructions on how to install the client app, or at least make the user more aware that it hasn't been installed without the error showing up in console. Some clients don't need the JSPM and some do, even though they use the same product.
The following func could be used as an alternative to detect whether the JSPM Client App is installed or not.
function is_jspm_installed(appPort) {
return new Promise((ok, er) => {
var ws = new WebSocket("wss://localhost:" + appPort)
ws.onmessage = (mj)=> {
try {
console.log(mj.data);
let m = JSON.parse(mj.data);
if("version" in m && "connection" in m && m["connection"] === "CONNECTED") {
ok(true)
return
}
}
catch(e) {
ok(false)
}
}
ws.onerror = _ => er("Error connecting WS")
ws.onclose = _ => er("Error connecting WS")
})
}
Each major version uses a specific port and that func can be called as follows depending on the version of our product that your websites is using...
// For V6
is_jspm_installed(26443).then((m) => console.info("V6 is installed")).catch((m) => console.error(m))
// For V5
is_jspm_installed(25443).then((m) => console.info("V5 is installed")).catch((m) => console.error(m))
// For V4
is_jspm_installed(24443).then((m) => console.info("V4 is installed")).catch((m) => console.error(m))
I use this library. So i have a problem that is JSPrintManager.js:2 WebSocket connection to 'wss://localhost:26443/' failed: in my hosted application. The Front End was deployed in AWS. However wanna solve this problem immediately. Please give me solution for me.