Socket – onError, onClose are not getting triggered
-
Deniz
2 days ago #62591I have this function which handles connections to multiple barcode scanners. I noticed that the onError and onClose events are not getting triggered, even when disconnecting the scanners.
Where can I find the socket class to inspect it? In Simplifier’s ‘Code’ section I can only find the js files for websocket, but not for socket.
I am relatively sure that these events still worked under Simplifier 8. Was there a change here in Simplifier 9?
function fxConnectSocket(sUrl, sVarName, fxOnData = () => {}) {
let socket = new Socket();
const aParts = sUrl.split(‘:’);
const iId = Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
const handleConnection = (status) => {
sap.ui.getCore().getModel(‘variableHolder’).setProperty(/${sVarName}
, status);
};
const reconnect = () => {
console.log(Socket ${iId} of type ${sVarName} connection to ${sUrl} closed. Reconnecting in 1 second...
);
setTimeout(() => socket = fxConnectSocket(sUrl, sVarName, fxOnData), 1000);
};
socket.open(aParts[0], parseInt(aParts[1]), () => {
handleConnection(‘Connected’);
console.log(Socket ${iId} of type ${sVarName} connection to ${sUrl} opened.
);
}, (event) => {
handleConnection(‘Disconnected’);
console.log(Socket ${iId} of type ${sVarName} connection to ${sUrl} failed with code ${JSON.stringify(event)}.
);
// reconnect();
});socket.onData = fxOnData;
socket.onError = function(event) {
handleConnection(‘Disconnected’);
console.error(Socket ${iId} of type ${sVarName} had an error:
, JSON.stringify(event))reconnect();
};
socket.onClose = function(event) {
handleConnection(‘Disconnected’);
console.log(Socket ${iId} of type ${sVarName} connection to ${sUrl} closed because of error ${JSON.stringify(event)}.
);
reconnect();
};return socket;
}- This topic was modified 2 days ago by Deniz.
Lukas Henninger
Has successfully completed the online course Introduction
Has successfully completed the online course Intermediate (200)
Has successfully completed the online course Advanced (300)
Has successfully completed the online course Basics (100)
Has successfully completed the online course Advanced (310)
Has successfully completed the online course Advanced (320)
5 hours ago #62617::Hi Deniz,
You can find the code for the sockets in our GitHub repository. This plugin is included in the mobile Client.
I don’t think there was a change in the Sockets code in recent times, so it should not be related to the update.
I hope this helps you out in identifying your issue.
Lukas
You must be logged in to reply to this topic.