<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title><![CDATA[Ewon Technical Forum - Java]]></title>
		<link>https://techforum.ewon.biz/</link>
		<description><![CDATA[Ewon Technical Forum - https://techforum.ewon.biz]]></description>
		<pubDate>Sun, 05 Apr 2026 21:15:56 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[Every Java program ends in "ZipException: bad header in central file directory"]]></title>
			<link>https://techforum.ewon.biz/thread-2851.html</link>
			<pubDate>Fri, 06 Feb 2026 17:20:37 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://techforum.ewon.biz/member.php?action=profile&uid=6496">cracksalad</a>]]></dc:creator>
			<guid isPermaLink="false">https://techforum.ewon.biz/thread-2851.html</guid>
			<description><![CDATA[Hi,<br />
<br />
I just started tinkering around with the Flexy 205 and want to write a Java program for MQTT as at least half of you guys seem to do. Sadly, I always run into <br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>java.util.zip.ZipException: bad header in central file directory<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Throwable.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Throwable.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Exception.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.io.IOException.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.util.zip.ZipException.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.util.zip.ZipFile.readEntries(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.util.zip.ZipFile.locateEndCD(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.util.zip.ZipFile.getEntries(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.util.zip.ZipFile.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.util.jar.JarFile.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.util.jar.JarFile.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at wonka.vm.ClassLoaderURLHandler.createClassLoaderURLHandler(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at wonka.vm.ClassLoaderURLHandler.createClassLoaderURLHandlers(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.net.URLClassLoader.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at wonka.vm.ApplicationClassLoader.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at wonka.vm.ApplicationClassLoader.getInstance(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.ClassLoader.createApplicationClassLoader(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.System.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.System.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at wonka.vm.Init.main(Unknown Source)<br />
Init: no such class as MainClass in class path!<br />
Init: no start class found.  Game over.</code></div></div><br />
<br />
I assume, that the last two lines are a consequence of the exception.<br />
<br />
I tried different JARs, a self made one as well as a MQTT_EWONSUPPORT.jar, which I found here in the forum.<br />
I execute the JVM/JAR by entering this URL in my browser:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>http://192.168.1.250/rcgi.bin/jvmCmd?cmd=start&amp;runCmd=%20-heapsize%205M%20-classpath%20/usr/MQTT_EWONSUPPORT.jar%20-emain%20MainClass</code></div></div><br />
Of course, I double checked the JAR name/path and the main class name. Is it possible, that e.g. a compression algorithm used by the JAR is not supported by the Ewon? Has anybody seen the same issue before? Do I have to enable somethingas one has to enable the FTP server since I think firmware 15?<br />
<br />
Firmware is 15.0s2]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
I just started tinkering around with the Flexy 205 and want to write a Java program for MQTT as at least half of you guys seem to do. Sadly, I always run into <br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>java.util.zip.ZipException: bad header in central file directory<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Throwable.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Throwable.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Exception.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.io.IOException.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.util.zip.ZipException.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.util.zip.ZipFile.readEntries(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.util.zip.ZipFile.locateEndCD(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.util.zip.ZipFile.getEntries(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.util.zip.ZipFile.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.util.jar.JarFile.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.util.jar.JarFile.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at wonka.vm.ClassLoaderURLHandler.createClassLoaderURLHandler(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at wonka.vm.ClassLoaderURLHandler.createClassLoaderURLHandlers(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.net.URLClassLoader.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at wonka.vm.ApplicationClassLoader.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at wonka.vm.ApplicationClassLoader.getInstance(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.ClassLoader.createApplicationClassLoader(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.System.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.System.(Unknown Source)<br />
&nbsp;&nbsp;&nbsp;&nbsp;at wonka.vm.Init.main(Unknown Source)<br />
Init: no such class as MainClass in class path!<br />
Init: no start class found.  Game over.</code></div></div><br />
<br />
I assume, that the last two lines are a consequence of the exception.<br />
<br />
I tried different JARs, a self made one as well as a MQTT_EWONSUPPORT.jar, which I found here in the forum.<br />
I execute the JVM/JAR by entering this URL in my browser:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>http://192.168.1.250/rcgi.bin/jvmCmd?cmd=start&amp;runCmd=%20-heapsize%205M%20-classpath%20/usr/MQTT_EWONSUPPORT.jar%20-emain%20MainClass</code></div></div><br />
Of course, I double checked the JAR name/path and the main class name. Is it possible, that e.g. a compression algorithm used by the JAR is not supported by the Ewon? Has anybody seen the same issue before? Do I have to enable somethingas one has to enable the FTP server since I think firmware 15?<br />
<br />
Firmware is 15.0s2]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Add apache-common-net.jar file V1.4.1]]></title>
			<link>https://techforum.ewon.biz/thread-2812.html</link>
			<pubDate>Wed, 26 Nov 2025 15:50:38 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://techforum.ewon.biz/member.php?action=profile&uid=5607">mickaa</a>]]></dc:creator>
			<guid isPermaLink="false">https://techforum.ewon.biz/thread-2812.html</guid>
			<description><![CDATA[Hello,<br />
<br />
I would like to add the apache-commons-net-ftp 1.4.1 (compatibility with compiler V1.3 in release note)  library to be able to list and delete files in a directory to the remote server.<br />
<br />
I imported it in Eclipse:<br />
<br />
import org.apache.commons.net.ftp.*;<br />
<br />
I don't get any compilation errors.<br />
The JVM stops with instruction: FTPClient: Myftp = new FTPClient();<br />
<br />
When I comment this line, the JVM does not break.<br />
<br />
Am I forgetting anything to integrate this library?]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
I would like to add the apache-commons-net-ftp 1.4.1 (compatibility with compiler V1.3 in release note)  library to be able to list and delete files in a directory to the remote server.<br />
<br />
I imported it in Eclipse:<br />
<br />
import org.apache.commons.net.ftp.*;<br />
<br />
I don't get any compilation errors.<br />
The JVM stops with instruction: FTPClient: Myftp = new FTPClient();<br />
<br />
When I comment this line, the JVM does not break.<br />
<br />
Am I forgetting anything to integrate this library?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Validating Wifi or internet connection]]></title>
			<link>https://techforum.ewon.biz/thread-2801.html</link>
			<pubDate>Thu, 09 Oct 2025 15:48:32 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://techforum.ewon.biz/member.php?action=profile&uid=4698">james.taylor@malonegroup.com</a>]]></dc:creator>
			<guid isPermaLink="false">https://techforum.ewon.biz/thread-2801.html</guid>
			<description><![CDATA[I have written a MQTT project for my Ewon Flexy 205, which appears to connect to my broker successfully, however i an gelling LOTS of messages in my error log<br />
<br />
<span style="text-decoration: underline;" class="mycode_u">Time                        | Event  | Description                           | Originator    </span>            <br />
09/10/2025 13:40:12 | 38003 | mqtt-Cannot start connection | jvmasync<br />
09/10/2025 13:40:12 | 38004 | mqtt-Connect failed               | jvmasync<br />
<br />
these are repeated alot and eventually, my Ewon reboots its self  (has just done it while writing this <img src="https://techforum.ewon.biz/images/smilies/sad.png" alt="Sad" title="Sad" class="smilie smilie_8" /> )<br />
<br />
<span style="text-decoration: underline;" class="mycode_u">Time                        | Event   | Description                                                                                | Originator  </span>  <br />
09/10/2025 09:32:27 | -22602 | System Booting, FWR: 14.9s4 (14.9), SN: 2210-0019-24 [EF0000]  | elog<br />
<br />
<br />
Sorry but i'm going pasting my class here in the hope someone can identify what is my issue:<br />
<br />
I recognise i have some loops in here that repeatedly try and connect to the broker in my void "EstablishConnection"<br />
<br />
When the " mqtt-Cannot start connection" messages appear, i dont have any entries in the log for "EstablishConnection: Retrying connection..." which leads me to believe that its not my code generating the errors, but something within <br />
the "com.ewon.ewonitf.MqttClient" library<br />
<br />
<br />
Now, is there any way i can use the SysControlBlock to check if my internet connection is established before i do any kind of connection to my broker?<br />
<br />
<br />
Thanks in advance.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>import java.util.ArrayList;<br />
import com.ewon.ewonitf.MqttMessage;<br />
import com.ewon.ewonitf.EWException;<br />
import com.ewon.ewonitf.IOManager;<br />
//import com.ewon.ewonitf.MqttClient;<br />
import com.ewon.ewonitf.SysControlBlock;<br />
<br />
/**<br />
 * MQTT_Thread<br />
 * <br />
 * Handles MQTT communication for an Ewon device.<br />
 * Periodically reads tag values, detects changes, and publishes data as JSON.<br />
 */<br />
public class MQTT_Thread implements Runnable {<br />
<br />
    private Thread thread = null;<br />
    private MQTTConfig config;<br />
    private boolean enable;<br />
    private String eWonSN = "";<br />
    private String commentPrefix = "********** ";<br />
    private String commentSuffix = " **********";<br />
    <br />
&nbsp;&nbsp;&nbsp;&nbsp;//  int mqtt_STATE_EXISTS = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;//  int mqtt_STATE_HAS_SEM = 1;<br />
&nbsp;&nbsp;&nbsp;&nbsp;//  int mqtt_STATE_HAS_LOCK = 2;<br />
&nbsp;&nbsp;&nbsp;&nbsp;  final int mqtt_STATE_LOOP_STARTED = 3;<br />
&nbsp;&nbsp;&nbsp;&nbsp;//  int mqtt_STATE_DISCONNECTED = 4;<br />
&nbsp;&nbsp;&nbsp;&nbsp;  final int mqtt_STATE_CONNECTED = 5;<br />
&nbsp;&nbsp;&nbsp;&nbsp;  <br />
    /**<br />
     * Start the MQTT thread if enabled in configuration.<br />
     */<br />
    public void start() throws Exception {<br />
        // Read the configuration file<br />
        config = new MQTTConfig();<br />
        <br />
        if (config.isValid()) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;        enable = config.enable();<br />
&nbsp;&nbsp;&nbsp;&nbsp;        <br />
&nbsp;&nbsp;&nbsp;&nbsp;        // Store the JSON<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try { IOManager.writeTag("Config_MQTT_Text", config.toString()); } <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;catch (Exception e) { System.out.println("Error Writing JSON To Tag: " + e.getLocalizedMessage()); }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;        if (enable) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;            WriteComment("Creating MQTT Thread");<br />
&nbsp;&nbsp;&nbsp;&nbsp;            // Create a new thread if enabled<br />
&nbsp;&nbsp;&nbsp;&nbsp;            if (thread == null) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                thread = new Thread(this);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                thread.start();<br />
&nbsp;&nbsp;&nbsp;&nbsp;            }<br />
&nbsp;&nbsp;&nbsp;&nbsp;        } else { WriteComment("MQTT Threads Disabled in Configuration"); }<br />
        } else { WriteComment("MQTT JSON Not Valid"); }<br />
    }<br />
<br />
    /**<br />
     * Main loop for reading and publishing MQTT data.<br />
     */    <br />
    public void run() {<br />
        try {<br />
        &nbsp;&nbsp;&nbsp;&nbsp;<br />
          &nbsp;&nbsp;WriteHeading("JAVA Started");<br />
        &nbsp;&nbsp;&nbsp;&nbsp;<br />
            // Create the System Control Block<br />
            SysControlBlock Sys = new SysControlBlock(SysControlBlock.INF);<br />
            // Save the Serial Number<br />
            eWonSN = Sys.getItem("SerNum");<br />
            <br />
            String topicPath = config.topicPath() + eWonSN;<br />
            int defaultTime = config.defaultTime();<br />
            int sleepTime = config.sleepTime();<br />
            int QOS = config.QOS();<br />
            String tagGroup = config.tagGroup();<br />
            ArrayList topics = config.topics();<br />
            <br />
            WriteHeading("MQTT Publush Settings");<br />
            WriteComment("MQTT Publush Settings: Topic: " + topicPath, true);<br />
            WriteComment("MQTT Publush Settings: Sleep Time: " + sleepTime + "ms", true);<br />
            WriteComment("MQTT Publush Settings: Sample Time: " + defaultTime + "s", true);<br />
            WriteComment("MQTT Publush Settings: QOS: " + QOS , true);<br />
            WriteComment("MQTT Publush Settings: tagGroup: " + tagGroup, true);<br />
            WriteHeading("MQTT Publush Settings");<br />
            <br />
            // MQTT Connected Status<br />
            boolean connected = false;<br />
            <br />
            // Create MQTT Client Object<br />
            MQTTClient Mqtt_c = null;<br />
     <br />
            // Establish a new connection<br />
            while (!connected) {<br />
            &nbsp;&nbsp;&nbsp;&nbsp;// Establish a new connection<br />
                Mqtt_c = EstablishConnection(Mqtt_c);<br />
                connected = isClientConnected(Mqtt_c);<br />
            }<br />
            <br />
            // Check a valid client exists<br />
            if (Mqtt_c != null ) {<br />
            &nbsp;&nbsp;&nbsp;&nbsp;// Are we connected?<br />
                connected = isClientConnected(Mqtt_c);   <br />
&nbsp;&nbsp;&nbsp;&nbsp;       <br />
&nbsp;&nbsp;&nbsp;&nbsp;            // Subscribe to all configured topics<br />
&nbsp;&nbsp;&nbsp;&nbsp;            for (int i = 0; i &lt; topics.size(); ++i) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                WriteComment("MQTT: Subscribing to " + topics.get(i).toString());<br />
&nbsp;&nbsp;&nbsp;&nbsp;                Mqtt_c.subscribe(topics.get(i).toString(), 0);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                WriteComment("MQTT: Subscription getStatus: " + Mqtt_c.getStatus());                <br />
&nbsp;&nbsp;&nbsp;&nbsp;            }<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;            // Define variables<br />
&nbsp;&nbsp;&nbsp;&nbsp;            int elapsedTime = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;            boolean valuesChanged = true; // Monitor changes in value<br />
&nbsp;&nbsp;&nbsp;&nbsp;            String ewonTag = "";<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;            // Convert default time to milliseconds<br />
&nbsp;&nbsp;&nbsp;&nbsp;            defaultTime = defaultTime * 1000;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;            // Create new Tags Handler<br />
&nbsp;&nbsp;&nbsp;&nbsp;            EwonTags myTags = new EwonTags();<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;            // Generate a list from the configured tag group<br />
&nbsp;&nbsp;&nbsp;&nbsp;            ArrayList tagList = myTags.GetGroupTags(tagGroup);<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;            // Default the Array to 1000 Tags to allow adding/removing during runtime<br />
&nbsp;&nbsp;&nbsp;&nbsp;            float[][] values = new float[1000][3];<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;            WriteHeading("MQTT Publish: Starting Tag monitoring Loop");<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;            // Main loop to read tag values<br />
&nbsp;&nbsp;&nbsp;&nbsp;            while (true) {    <br />
&nbsp;&nbsp;&nbsp;&nbsp;            &nbsp;&nbsp;&nbsp;&nbsp;// Get the connected Status<br />
&nbsp;&nbsp;&nbsp;&nbsp;                connected = isClientConnected(Mqtt_c);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                <br />
&nbsp;&nbsp;&nbsp;&nbsp;            &nbsp;&nbsp;&nbsp;&nbsp;// Loop until we can connect<br />
&nbsp;&nbsp;&nbsp;&nbsp;                while (!connected) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                &nbsp;&nbsp;&nbsp;&nbsp;// Establish a new connection<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    Mqtt_c = EstablishConnection(Mqtt_c);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    connected = isClientConnected(Mqtt_c);   <br />
&nbsp;&nbsp;&nbsp;&nbsp;                }<br />
&nbsp;&nbsp;&nbsp;&nbsp;            &nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                // Record current time in milliseconds (Epoch)<br />
&nbsp;&nbsp;&nbsp;&nbsp;                long epoch = System.currentTimeMillis();<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                try {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    // Get the number of tags<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    int tagCount = tagList.size();<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    for (int i = 0; i &lt; tagCount; i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                        if (i &lt; tagCount) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            // Update previous value<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            values[i][1] = values[i][0];<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            ewonTag = (String) tagList.get(i);<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            try {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                // Skip if tag previously had an error<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                if (values[i][2] != -1) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                    // Read current tag value<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                    values[i][0] = com.ewon.ewonitf.IOManager.readTagAsFloat(ewonTag);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                    values[i][2] = 0; // Error = False<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                    // Detect change<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                    if (values[i][0] != values[i][1]) { valuesChanged = true; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                }<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            } catch (Exception ex) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                handleError(ex, "Error with Tag: &#92;"" + ewonTag + "&#92;" msg:");<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                values[i][0] = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                values[i][1] = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                values[i][2] = -1; // Set Reading Error = True<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            }<br />
&nbsp;&nbsp;&nbsp;&nbsp;                        } else {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            // Reset unused values<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            values[i][0] = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            values[i][1] = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            values[i][2] = -1;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                        }<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    }<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    // If time or values changed, publish messages<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    if ((elapsedTime &gt;= (defaultTime - sleepTime)) || valuesChanged) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                        // For each tag, publish message<br />
&nbsp;&nbsp;&nbsp;&nbsp;                        for (int i = 0; i &lt; tagCount; i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            if (values[i][2] == 0) { // Read OK<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                ewonTag = (String) tagList.get(i);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                String topic = topicPath;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                // Build JSON payload<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                JSONObject payload = new JSONObject();<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                payload.put("time", String.valueOf(epoch));<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                payload.put("id", ewonTag);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                payload.put("pv", String.valueOf(values[i][0]));<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                &nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                try {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                &nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                &nbsp;&nbsp;&nbsp;&nbsp;// Get the connected Status<br />
&nbsp;&nbsp;&nbsp;&nbsp;                &nbsp;&nbsp;&nbsp;&nbsp;                connected = isClientConnected(Mqtt_c);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                &nbsp;&nbsp;&nbsp;&nbsp;if (connected) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                                // Publish new message (no retain)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                                Mqtt_c.publish(new MqttMessage(topic, payload.toString()), QOS, false);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                                WriteComment("MQTT : value published: " + payload);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                                } else { WriteComment("MQTT : value NOT published: Mqtt_c.GetStatus: " + Mqtt_c.getStatus()); }<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                } <br />
&nbsp;&nbsp;&nbsp;&nbsp;                                catch (EWException ex) { handleError(ex, "EWException in loop:"); }<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                catch (Exception ex) { handleError(ex, "Exception in loop:"); }<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                <br />
&nbsp;&nbsp;&nbsp;&nbsp;                            }<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            // Reset error flag<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            values[i][2] = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                        }<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                        // Rebuild the tag list in case tags have changed dynamically<br />
&nbsp;&nbsp;&nbsp;&nbsp;                        tagList = myTags.GetGroupTags(tagGroup);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    }<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    // Reset timer if needed<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    if (elapsedTime &gt;= (defaultTime - sleepTime)) { elapsedTime = 0; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                } catch (Exception ex) { handleError(ex, "Error in loop:");}<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                // Calculate when to run again<br />
&nbsp;&nbsp;&nbsp;&nbsp;                long deltaTime = sleepTime - (System.currentTimeMillis() - epoch);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                deltaTime = Math.max(deltaTime, 1000); // Prevent negative sleep times<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                // Add asleep between checking values<br />
&nbsp;&nbsp;&nbsp;&nbsp;                try { Thread.sleep(deltaTime); } <br />
&nbsp;&nbsp;&nbsp;&nbsp;                catch (InterruptedException e) { e.printStackTrace();}                <br />
&nbsp;&nbsp;&nbsp;&nbsp;                <br />
&nbsp;&nbsp;&nbsp;&nbsp;                // Reset changed flag<br />
&nbsp;&nbsp;&nbsp;&nbsp;                valuesChanged = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                elapsedTime += deltaTime;<br />
&nbsp;&nbsp;&nbsp;&nbsp;            }&nbsp;&nbsp;&nbsp;&nbsp;            <br />
            }<br />
        } catch (Exception ex) { handleError(ex, "Error occurred:"); }        <br />
    }<br />
    <br />
    /**<br />
     * Handle a Throwable Error with a comment<br />
     * @param ex<br />
     * @param comment<br />
     */<br />
    public void handleError(Throwable ex, String error) {<br />
    &nbsp;&nbsp;&nbsp;&nbsp;if (error != null &amp;&amp; !error.equals("")) { WriteError(error + ' ' + ex.getLocalizedMessage());}<br />
    &nbsp;&nbsp;&nbsp;&nbsp;ex.printStackTrace(System.err); // ensures it prints to stderr<br />
    }<br />
    <br />
    /**<br />
     * Handle a Throwable Error<br />
     * @param ex<br />
     */<br />
    public void handleError(Throwable ex) {<br />
        handleError(ex, null);<br />
    }<br />
    <br />
    /**<br />
     * Establish new connection<br />
     * @param existingClient the current MQTT client, may be null<br />
     * @return a connected MQTTClient instance, or null if connection fails<br />
     */<br />
    public MQTTClient EstablishConnection(MQTTClient existingClient) {<br />
<br />
    &nbsp;&nbsp;&nbsp;&nbsp;int maxRetries = 50; // Limit the number of retries<br />
        int retryDelayMs = 5000; // Set a reconnection delay<br />
        <br />
        boolean connected = false;<br />
        MQTTClient client = existingClient;<br />
<br />
        // Read configuration parameters<br />
        String brokerHost = config.brokerHost();<br />
        String brokerPort = config.brokerPort();<br />
        String brokerUsername = config.brokerUsername();<br />
        String brokerPassword = config.brokerPassword();<br />
        String brokerLog = config.brokerLog();<br />
        boolean brokerUseCert = config.brokerUseCert();<br />
<br />
        try {<br />
            if (client == null) {<br />
<br />
                WriteHeading("EstablishConnection: Initilise Connection");<br />
                WriteComment("Broker Settings: JAVA Script Starting", true);<br />
                WriteComment("Broker Settings: ClientID: " + eWonSN + " (Ewon Serial Number)", true);<br />
                WriteComment("Broker Settings: Host: " + brokerHost + ", Port: " + brokerPort, true);<br />
                if (brokerUsername != null &amp;&amp; !brokerUsername.equals("")) {<br />
                    WriteComment("Broker Settings: Username: " + brokerUsername, true);<br />
                    WriteComment("Broker Settings: Password: " + brokerPassword, true);<br />
                }<br />
                WriteComment("Broker Settings: Logging: " + brokerLog, true);      <br />
                WriteComment("Broker Settings: Use Certificates: " + brokerUseCert, true);                <br />
<br />
                // Create MQTT Client Object<br />
                client = new MQTTClient(eWonSN, brokerHost);<br />
<br />
                // Set Broker Port and options<br />
                client.setOption("port", brokerPort);<br />
<br />
                // Set the Username and Password if provided<br />
                if (brokerUsername != null &amp;&amp; !brokerUsername.equals("")) {<br />
                    client.setOption("Username", brokerUsername);<br />
                    client.setOption("Password", brokerPassword);<br />
                }<br />
<br />
                // Set the logging value<br />
                client.setOption("log", brokerLog);<br />
<br />
                // Assign the Certificates to the device<br />
                try {<br />
                    WriteComment("Broker Settings: Loading Certificates:", true);<br />
                    client.setOption("cafile", "/usr/isrgrootx1.pem");<br />
                    if (brokerUseCert) {<br />
                        client.setOption("certfile", "/usr/plc.cert.pem");<br />
                        client.setOption("keyfile", "/usr/plc.key.pem");<br />
                    }<br />
                } catch (Exception ex) { handleError(ex, "Error occurred:"); }<br />
                <br />
                WriteHeading("EstablishConnection: Client Configured");                <br />
            }<br />
<br />
            // Check if client is connected<br />
            connected = isClientConnected(client);<br />
            <br />
            for (int attempt = 1; attempt &lt;= maxRetries; attempt++) {<br />
            //while (!connected) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;            // Attempt to connect<br />
&nbsp;&nbsp;&nbsp;&nbsp;            WriteComment("EstablishConnection: Attempting to Connect...");<br />
&nbsp;&nbsp;&nbsp;&nbsp;            client.connect();<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;            int status = client.getStatus();<br />
&nbsp;&nbsp;&nbsp;&nbsp;            connected = isClientConnected(client);&nbsp;&nbsp;&nbsp;&nbsp;            <br />
&nbsp;&nbsp;&nbsp;&nbsp;            if (connected) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;            &nbsp;&nbsp;&nbsp;&nbsp;WriteComment("Mqtt_c.GetStatus: " + status);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            WriteComment("EstablishConnection: Connected to: " + brokerHost + ":" + brokerPort);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            WriteHeading("EstablishConnection: Client Connected");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            return client; // success<br />
&nbsp;&nbsp;&nbsp;&nbsp;            } else {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                WriteComment("EstablishConnection: Retrying connection...");<br />
&nbsp;&nbsp;&nbsp;&nbsp;                try {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    Thread.sleep(retryDelayMs);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                } catch (InterruptedException ie) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    Thread.currentThread().interrupt();<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    WriteError("EstablishConnection: Thread interupted");<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    break; // stop retrying if thread interrupted<br />
&nbsp;&nbsp;&nbsp;&nbsp;                }<br />
&nbsp;&nbsp;&nbsp;&nbsp;            }<br />
            }<br />
            <br />
            WriteError("Failed to connect after " + maxRetries + " attempts");<br />
            return client; // success<br />
        } <br />
        catch (EWException ex) { handleError(ex, "EstablishConnection: EWException:"); }<br />
        catch (Exception ex) { handleError(ex, "EstablishConnection: Exception:"); }<br />
        <br />
        return null; // failed connection<br />
    }<br />
<br />
    /**<br />
     * Establish new connection<br />
     * @param existingClient the current MQTT client, may be null<br />
     * @return a connected MQTTClient instance, or null if connection fails<br />
     */<br />
    public boolean isClientConnected(MQTTClient existingClient) {<br />
    &nbsp;&nbsp;&nbsp;&nbsp;int status = 0;<br />
    &nbsp;&nbsp;&nbsp;&nbsp;boolean connected = false;<br />
    &nbsp;&nbsp;&nbsp;&nbsp;try {<br />
&nbsp;&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;&nbsp;if (existingClient != null ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;            // Get the connected Status<br />
&nbsp;&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;status = existingClient.getStatus();<br />
&nbsp;&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;connected =(status == mqtt_STATE_CONNECTED || status == mqtt_STATE_LOOP_STARTED);<br />
&nbsp;&nbsp;&nbsp;&nbsp;        } <br />
    &nbsp;&nbsp;&nbsp;&nbsp;} <br />
    &nbsp;&nbsp;&nbsp;&nbsp;catch (EWException ex) { handleError(ex, "isClientConnected: EWException:"); }<br />
    &nbsp;&nbsp;&nbsp;&nbsp;return connected;<br />
    }<br />
    <br />
    /**<br />
     * Write a comment to the Log<br />
     * @param comment<br />
     * @param includePrefix<br />
     */<br />
    public void WriteComment(String comment, boolean includePrefix) {    &nbsp;&nbsp;&nbsp;&nbsp;<br />
    &nbsp;&nbsp;&nbsp;&nbsp;if (includePrefix) { comment = commentPrefix + comment;}<br />
    &nbsp;&nbsp;&nbsp;&nbsp;System.out.println(comment);<br />
    }<br />
    <br />
    /**<br />
     * Write a comment to the Log<br />
     * @param comment<br />
     */<br />
    public void WriteComment(String comment) {<br />
    &nbsp;&nbsp;&nbsp;&nbsp;WriteComment(comment, false);<br />
    }<br />
    <br />
    /**<br />
     * Write a Heading to the Log <br />
     * @param comment<br />
     */<br />
    public void WriteHeading(String comment) {<br />
    &nbsp;&nbsp;&nbsp;&nbsp;System.out.println(commentPrefix + comment + commentSuffix);<br />
    }<br />
    <br />
    <br />
    /**<br />
     * Write an error to the Log<br />
     * @param error<br />
     */<br />
    public void WriteError(String error) {<br />
    &nbsp;&nbsp;&nbsp;&nbsp;System.out.println(error);<br />
    }<br />
}</code></div></div>]]></description>
			<content:encoded><![CDATA[I have written a MQTT project for my Ewon Flexy 205, which appears to connect to my broker successfully, however i an gelling LOTS of messages in my error log<br />
<br />
<span style="text-decoration: underline;" class="mycode_u">Time                        | Event  | Description                           | Originator    </span>            <br />
09/10/2025 13:40:12 | 38003 | mqtt-Cannot start connection | jvmasync<br />
09/10/2025 13:40:12 | 38004 | mqtt-Connect failed               | jvmasync<br />
<br />
these are repeated alot and eventually, my Ewon reboots its self  (has just done it while writing this <img src="https://techforum.ewon.biz/images/smilies/sad.png" alt="Sad" title="Sad" class="smilie smilie_8" /> )<br />
<br />
<span style="text-decoration: underline;" class="mycode_u">Time                        | Event   | Description                                                                                | Originator  </span>  <br />
09/10/2025 09:32:27 | -22602 | System Booting, FWR: 14.9s4 (14.9), SN: 2210-0019-24 [EF0000]  | elog<br />
<br />
<br />
Sorry but i'm going pasting my class here in the hope someone can identify what is my issue:<br />
<br />
I recognise i have some loops in here that repeatedly try and connect to the broker in my void "EstablishConnection"<br />
<br />
When the " mqtt-Cannot start connection" messages appear, i dont have any entries in the log for "EstablishConnection: Retrying connection..." which leads me to believe that its not my code generating the errors, but something within <br />
the "com.ewon.ewonitf.MqttClient" library<br />
<br />
<br />
Now, is there any way i can use the SysControlBlock to check if my internet connection is established before i do any kind of connection to my broker?<br />
<br />
<br />
Thanks in advance.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>import java.util.ArrayList;<br />
import com.ewon.ewonitf.MqttMessage;<br />
import com.ewon.ewonitf.EWException;<br />
import com.ewon.ewonitf.IOManager;<br />
//import com.ewon.ewonitf.MqttClient;<br />
import com.ewon.ewonitf.SysControlBlock;<br />
<br />
/**<br />
 * MQTT_Thread<br />
 * <br />
 * Handles MQTT communication for an Ewon device.<br />
 * Periodically reads tag values, detects changes, and publishes data as JSON.<br />
 */<br />
public class MQTT_Thread implements Runnable {<br />
<br />
    private Thread thread = null;<br />
    private MQTTConfig config;<br />
    private boolean enable;<br />
    private String eWonSN = "";<br />
    private String commentPrefix = "********** ";<br />
    private String commentSuffix = " **********";<br />
    <br />
&nbsp;&nbsp;&nbsp;&nbsp;//  int mqtt_STATE_EXISTS = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;//  int mqtt_STATE_HAS_SEM = 1;<br />
&nbsp;&nbsp;&nbsp;&nbsp;//  int mqtt_STATE_HAS_LOCK = 2;<br />
&nbsp;&nbsp;&nbsp;&nbsp;  final int mqtt_STATE_LOOP_STARTED = 3;<br />
&nbsp;&nbsp;&nbsp;&nbsp;//  int mqtt_STATE_DISCONNECTED = 4;<br />
&nbsp;&nbsp;&nbsp;&nbsp;  final int mqtt_STATE_CONNECTED = 5;<br />
&nbsp;&nbsp;&nbsp;&nbsp;  <br />
    /**<br />
     * Start the MQTT thread if enabled in configuration.<br />
     */<br />
    public void start() throws Exception {<br />
        // Read the configuration file<br />
        config = new MQTTConfig();<br />
        <br />
        if (config.isValid()) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;        enable = config.enable();<br />
&nbsp;&nbsp;&nbsp;&nbsp;        <br />
&nbsp;&nbsp;&nbsp;&nbsp;        // Store the JSON<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try { IOManager.writeTag("Config_MQTT_Text", config.toString()); } <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;catch (Exception e) { System.out.println("Error Writing JSON To Tag: " + e.getLocalizedMessage()); }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;        if (enable) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;            WriteComment("Creating MQTT Thread");<br />
&nbsp;&nbsp;&nbsp;&nbsp;            // Create a new thread if enabled<br />
&nbsp;&nbsp;&nbsp;&nbsp;            if (thread == null) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                thread = new Thread(this);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                thread.start();<br />
&nbsp;&nbsp;&nbsp;&nbsp;            }<br />
&nbsp;&nbsp;&nbsp;&nbsp;        } else { WriteComment("MQTT Threads Disabled in Configuration"); }<br />
        } else { WriteComment("MQTT JSON Not Valid"); }<br />
    }<br />
<br />
    /**<br />
     * Main loop for reading and publishing MQTT data.<br />
     */    <br />
    public void run() {<br />
        try {<br />
        &nbsp;&nbsp;&nbsp;&nbsp;<br />
          &nbsp;&nbsp;WriteHeading("JAVA Started");<br />
        &nbsp;&nbsp;&nbsp;&nbsp;<br />
            // Create the System Control Block<br />
            SysControlBlock Sys = new SysControlBlock(SysControlBlock.INF);<br />
            // Save the Serial Number<br />
            eWonSN = Sys.getItem("SerNum");<br />
            <br />
            String topicPath = config.topicPath() + eWonSN;<br />
            int defaultTime = config.defaultTime();<br />
            int sleepTime = config.sleepTime();<br />
            int QOS = config.QOS();<br />
            String tagGroup = config.tagGroup();<br />
            ArrayList topics = config.topics();<br />
            <br />
            WriteHeading("MQTT Publush Settings");<br />
            WriteComment("MQTT Publush Settings: Topic: " + topicPath, true);<br />
            WriteComment("MQTT Publush Settings: Sleep Time: " + sleepTime + "ms", true);<br />
            WriteComment("MQTT Publush Settings: Sample Time: " + defaultTime + "s", true);<br />
            WriteComment("MQTT Publush Settings: QOS: " + QOS , true);<br />
            WriteComment("MQTT Publush Settings: tagGroup: " + tagGroup, true);<br />
            WriteHeading("MQTT Publush Settings");<br />
            <br />
            // MQTT Connected Status<br />
            boolean connected = false;<br />
            <br />
            // Create MQTT Client Object<br />
            MQTTClient Mqtt_c = null;<br />
     <br />
            // Establish a new connection<br />
            while (!connected) {<br />
            &nbsp;&nbsp;&nbsp;&nbsp;// Establish a new connection<br />
                Mqtt_c = EstablishConnection(Mqtt_c);<br />
                connected = isClientConnected(Mqtt_c);<br />
            }<br />
            <br />
            // Check a valid client exists<br />
            if (Mqtt_c != null ) {<br />
            &nbsp;&nbsp;&nbsp;&nbsp;// Are we connected?<br />
                connected = isClientConnected(Mqtt_c);   <br />
&nbsp;&nbsp;&nbsp;&nbsp;       <br />
&nbsp;&nbsp;&nbsp;&nbsp;            // Subscribe to all configured topics<br />
&nbsp;&nbsp;&nbsp;&nbsp;            for (int i = 0; i &lt; topics.size(); ++i) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                WriteComment("MQTT: Subscribing to " + topics.get(i).toString());<br />
&nbsp;&nbsp;&nbsp;&nbsp;                Mqtt_c.subscribe(topics.get(i).toString(), 0);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                WriteComment("MQTT: Subscription getStatus: " + Mqtt_c.getStatus());                <br />
&nbsp;&nbsp;&nbsp;&nbsp;            }<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;            // Define variables<br />
&nbsp;&nbsp;&nbsp;&nbsp;            int elapsedTime = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;            boolean valuesChanged = true; // Monitor changes in value<br />
&nbsp;&nbsp;&nbsp;&nbsp;            String ewonTag = "";<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;            // Convert default time to milliseconds<br />
&nbsp;&nbsp;&nbsp;&nbsp;            defaultTime = defaultTime * 1000;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;            // Create new Tags Handler<br />
&nbsp;&nbsp;&nbsp;&nbsp;            EwonTags myTags = new EwonTags();<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;            // Generate a list from the configured tag group<br />
&nbsp;&nbsp;&nbsp;&nbsp;            ArrayList tagList = myTags.GetGroupTags(tagGroup);<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;            // Default the Array to 1000 Tags to allow adding/removing during runtime<br />
&nbsp;&nbsp;&nbsp;&nbsp;            float[][] values = new float[1000][3];<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;            WriteHeading("MQTT Publish: Starting Tag monitoring Loop");<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;            // Main loop to read tag values<br />
&nbsp;&nbsp;&nbsp;&nbsp;            while (true) {    <br />
&nbsp;&nbsp;&nbsp;&nbsp;            &nbsp;&nbsp;&nbsp;&nbsp;// Get the connected Status<br />
&nbsp;&nbsp;&nbsp;&nbsp;                connected = isClientConnected(Mqtt_c);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                <br />
&nbsp;&nbsp;&nbsp;&nbsp;            &nbsp;&nbsp;&nbsp;&nbsp;// Loop until we can connect<br />
&nbsp;&nbsp;&nbsp;&nbsp;                while (!connected) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                &nbsp;&nbsp;&nbsp;&nbsp;// Establish a new connection<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    Mqtt_c = EstablishConnection(Mqtt_c);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    connected = isClientConnected(Mqtt_c);   <br />
&nbsp;&nbsp;&nbsp;&nbsp;                }<br />
&nbsp;&nbsp;&nbsp;&nbsp;            &nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                // Record current time in milliseconds (Epoch)<br />
&nbsp;&nbsp;&nbsp;&nbsp;                long epoch = System.currentTimeMillis();<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                try {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    // Get the number of tags<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    int tagCount = tagList.size();<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    for (int i = 0; i &lt; tagCount; i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                        if (i &lt; tagCount) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            // Update previous value<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            values[i][1] = values[i][0];<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            ewonTag = (String) tagList.get(i);<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            try {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                // Skip if tag previously had an error<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                if (values[i][2] != -1) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                    // Read current tag value<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                    values[i][0] = com.ewon.ewonitf.IOManager.readTagAsFloat(ewonTag);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                    values[i][2] = 0; // Error = False<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                    // Detect change<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                    if (values[i][0] != values[i][1]) { valuesChanged = true; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                }<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            } catch (Exception ex) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                handleError(ex, "Error with Tag: &#92;"" + ewonTag + "&#92;" msg:");<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                values[i][0] = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                values[i][1] = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                values[i][2] = -1; // Set Reading Error = True<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            }<br />
&nbsp;&nbsp;&nbsp;&nbsp;                        } else {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            // Reset unused values<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            values[i][0] = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            values[i][1] = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            values[i][2] = -1;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                        }<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    }<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    // If time or values changed, publish messages<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    if ((elapsedTime &gt;= (defaultTime - sleepTime)) || valuesChanged) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                        // For each tag, publish message<br />
&nbsp;&nbsp;&nbsp;&nbsp;                        for (int i = 0; i &lt; tagCount; i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            if (values[i][2] == 0) { // Read OK<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                ewonTag = (String) tagList.get(i);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                String topic = topicPath;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                // Build JSON payload<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                JSONObject payload = new JSONObject();<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                payload.put("time", String.valueOf(epoch));<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                payload.put("id", ewonTag);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                payload.put("pv", String.valueOf(values[i][0]));<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                &nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                try {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                &nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                &nbsp;&nbsp;&nbsp;&nbsp;// Get the connected Status<br />
&nbsp;&nbsp;&nbsp;&nbsp;                &nbsp;&nbsp;&nbsp;&nbsp;                connected = isClientConnected(Mqtt_c);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                &nbsp;&nbsp;&nbsp;&nbsp;if (connected) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                                // Publish new message (no retain)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                                Mqtt_c.publish(new MqttMessage(topic, payload.toString()), QOS, false);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                                WriteComment("MQTT : value published: " + payload);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                                } else { WriteComment("MQTT : value NOT published: Mqtt_c.GetStatus: " + Mqtt_c.getStatus()); }<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                } <br />
&nbsp;&nbsp;&nbsp;&nbsp;                                catch (EWException ex) { handleError(ex, "EWException in loop:"); }<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                catch (Exception ex) { handleError(ex, "Exception in loop:"); }<br />
&nbsp;&nbsp;&nbsp;&nbsp;                                <br />
&nbsp;&nbsp;&nbsp;&nbsp;                            }<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            // Reset error flag<br />
&nbsp;&nbsp;&nbsp;&nbsp;                            values[i][2] = 0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                        }<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                        // Rebuild the tag list in case tags have changed dynamically<br />
&nbsp;&nbsp;&nbsp;&nbsp;                        tagList = myTags.GetGroupTags(tagGroup);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    }<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    // Reset timer if needed<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    if (elapsedTime &gt;= (defaultTime - sleepTime)) { elapsedTime = 0; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                } catch (Exception ex) { handleError(ex, "Error in loop:");}<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                // Calculate when to run again<br />
&nbsp;&nbsp;&nbsp;&nbsp;                long deltaTime = sleepTime - (System.currentTimeMillis() - epoch);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                deltaTime = Math.max(deltaTime, 1000); // Prevent negative sleep times<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                // Add asleep between checking values<br />
&nbsp;&nbsp;&nbsp;&nbsp;                try { Thread.sleep(deltaTime); } <br />
&nbsp;&nbsp;&nbsp;&nbsp;                catch (InterruptedException e) { e.printStackTrace();}                <br />
&nbsp;&nbsp;&nbsp;&nbsp;                <br />
&nbsp;&nbsp;&nbsp;&nbsp;                // Reset changed flag<br />
&nbsp;&nbsp;&nbsp;&nbsp;                valuesChanged = false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;                elapsedTime += deltaTime;<br />
&nbsp;&nbsp;&nbsp;&nbsp;            }&nbsp;&nbsp;&nbsp;&nbsp;            <br />
            }<br />
        } catch (Exception ex) { handleError(ex, "Error occurred:"); }        <br />
    }<br />
    <br />
    /**<br />
     * Handle a Throwable Error with a comment<br />
     * @param ex<br />
     * @param comment<br />
     */<br />
    public void handleError(Throwable ex, String error) {<br />
    &nbsp;&nbsp;&nbsp;&nbsp;if (error != null &amp;&amp; !error.equals("")) { WriteError(error + ' ' + ex.getLocalizedMessage());}<br />
    &nbsp;&nbsp;&nbsp;&nbsp;ex.printStackTrace(System.err); // ensures it prints to stderr<br />
    }<br />
    <br />
    /**<br />
     * Handle a Throwable Error<br />
     * @param ex<br />
     */<br />
    public void handleError(Throwable ex) {<br />
        handleError(ex, null);<br />
    }<br />
    <br />
    /**<br />
     * Establish new connection<br />
     * @param existingClient the current MQTT client, may be null<br />
     * @return a connected MQTTClient instance, or null if connection fails<br />
     */<br />
    public MQTTClient EstablishConnection(MQTTClient existingClient) {<br />
<br />
    &nbsp;&nbsp;&nbsp;&nbsp;int maxRetries = 50; // Limit the number of retries<br />
        int retryDelayMs = 5000; // Set a reconnection delay<br />
        <br />
        boolean connected = false;<br />
        MQTTClient client = existingClient;<br />
<br />
        // Read configuration parameters<br />
        String brokerHost = config.brokerHost();<br />
        String brokerPort = config.brokerPort();<br />
        String brokerUsername = config.brokerUsername();<br />
        String brokerPassword = config.brokerPassword();<br />
        String brokerLog = config.brokerLog();<br />
        boolean brokerUseCert = config.brokerUseCert();<br />
<br />
        try {<br />
            if (client == null) {<br />
<br />
                WriteHeading("EstablishConnection: Initilise Connection");<br />
                WriteComment("Broker Settings: JAVA Script Starting", true);<br />
                WriteComment("Broker Settings: ClientID: " + eWonSN + " (Ewon Serial Number)", true);<br />
                WriteComment("Broker Settings: Host: " + brokerHost + ", Port: " + brokerPort, true);<br />
                if (brokerUsername != null &amp;&amp; !brokerUsername.equals("")) {<br />
                    WriteComment("Broker Settings: Username: " + brokerUsername, true);<br />
                    WriteComment("Broker Settings: Password: " + brokerPassword, true);<br />
                }<br />
                WriteComment("Broker Settings: Logging: " + brokerLog, true);      <br />
                WriteComment("Broker Settings: Use Certificates: " + brokerUseCert, true);                <br />
<br />
                // Create MQTT Client Object<br />
                client = new MQTTClient(eWonSN, brokerHost);<br />
<br />
                // Set Broker Port and options<br />
                client.setOption("port", brokerPort);<br />
<br />
                // Set the Username and Password if provided<br />
                if (brokerUsername != null &amp;&amp; !brokerUsername.equals("")) {<br />
                    client.setOption("Username", brokerUsername);<br />
                    client.setOption("Password", brokerPassword);<br />
                }<br />
<br />
                // Set the logging value<br />
                client.setOption("log", brokerLog);<br />
<br />
                // Assign the Certificates to the device<br />
                try {<br />
                    WriteComment("Broker Settings: Loading Certificates:", true);<br />
                    client.setOption("cafile", "/usr/isrgrootx1.pem");<br />
                    if (brokerUseCert) {<br />
                        client.setOption("certfile", "/usr/plc.cert.pem");<br />
                        client.setOption("keyfile", "/usr/plc.key.pem");<br />
                    }<br />
                } catch (Exception ex) { handleError(ex, "Error occurred:"); }<br />
                <br />
                WriteHeading("EstablishConnection: Client Configured");                <br />
            }<br />
<br />
            // Check if client is connected<br />
            connected = isClientConnected(client);<br />
            <br />
            for (int attempt = 1; attempt &lt;= maxRetries; attempt++) {<br />
            //while (!connected) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;            // Attempt to connect<br />
&nbsp;&nbsp;&nbsp;&nbsp;            WriteComment("EstablishConnection: Attempting to Connect...");<br />
&nbsp;&nbsp;&nbsp;&nbsp;            client.connect();<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;            int status = client.getStatus();<br />
&nbsp;&nbsp;&nbsp;&nbsp;            connected = isClientConnected(client);&nbsp;&nbsp;&nbsp;&nbsp;            <br />
&nbsp;&nbsp;&nbsp;&nbsp;            if (connected) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;            &nbsp;&nbsp;&nbsp;&nbsp;WriteComment("Mqtt_c.GetStatus: " + status);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            WriteComment("EstablishConnection: Connected to: " + brokerHost + ":" + brokerPort);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            WriteHeading("EstablishConnection: Client Connected");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            return client; // success<br />
&nbsp;&nbsp;&nbsp;&nbsp;            } else {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                WriteComment("EstablishConnection: Retrying connection...");<br />
&nbsp;&nbsp;&nbsp;&nbsp;                try {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    Thread.sleep(retryDelayMs);<br />
&nbsp;&nbsp;&nbsp;&nbsp;                } catch (InterruptedException ie) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    Thread.currentThread().interrupt();<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    WriteError("EstablishConnection: Thread interupted");<br />
&nbsp;&nbsp;&nbsp;&nbsp;                    break; // stop retrying if thread interrupted<br />
&nbsp;&nbsp;&nbsp;&nbsp;                }<br />
&nbsp;&nbsp;&nbsp;&nbsp;            }<br />
            }<br />
            <br />
            WriteError("Failed to connect after " + maxRetries + " attempts");<br />
            return client; // success<br />
        } <br />
        catch (EWException ex) { handleError(ex, "EstablishConnection: EWException:"); }<br />
        catch (Exception ex) { handleError(ex, "EstablishConnection: Exception:"); }<br />
        <br />
        return null; // failed connection<br />
    }<br />
<br />
    /**<br />
     * Establish new connection<br />
     * @param existingClient the current MQTT client, may be null<br />
     * @return a connected MQTTClient instance, or null if connection fails<br />
     */<br />
    public boolean isClientConnected(MQTTClient existingClient) {<br />
    &nbsp;&nbsp;&nbsp;&nbsp;int status = 0;<br />
    &nbsp;&nbsp;&nbsp;&nbsp;boolean connected = false;<br />
    &nbsp;&nbsp;&nbsp;&nbsp;try {<br />
&nbsp;&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;&nbsp;if (existingClient != null ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;            // Get the connected Status<br />
&nbsp;&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;status = existingClient.getStatus();<br />
&nbsp;&nbsp;&nbsp;&nbsp;    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;connected =(status == mqtt_STATE_CONNECTED || status == mqtt_STATE_LOOP_STARTED);<br />
&nbsp;&nbsp;&nbsp;&nbsp;        } <br />
    &nbsp;&nbsp;&nbsp;&nbsp;} <br />
    &nbsp;&nbsp;&nbsp;&nbsp;catch (EWException ex) { handleError(ex, "isClientConnected: EWException:"); }<br />
    &nbsp;&nbsp;&nbsp;&nbsp;return connected;<br />
    }<br />
    <br />
    /**<br />
     * Write a comment to the Log<br />
     * @param comment<br />
     * @param includePrefix<br />
     */<br />
    public void WriteComment(String comment, boolean includePrefix) {    &nbsp;&nbsp;&nbsp;&nbsp;<br />
    &nbsp;&nbsp;&nbsp;&nbsp;if (includePrefix) { comment = commentPrefix + comment;}<br />
    &nbsp;&nbsp;&nbsp;&nbsp;System.out.println(comment);<br />
    }<br />
    <br />
    /**<br />
     * Write a comment to the Log<br />
     * @param comment<br />
     */<br />
    public void WriteComment(String comment) {<br />
    &nbsp;&nbsp;&nbsp;&nbsp;WriteComment(comment, false);<br />
    }<br />
    <br />
    /**<br />
     * Write a Heading to the Log <br />
     * @param comment<br />
     */<br />
    public void WriteHeading(String comment) {<br />
    &nbsp;&nbsp;&nbsp;&nbsp;System.out.println(commentPrefix + comment + commentSuffix);<br />
    }<br />
    <br />
    <br />
    /**<br />
     * Write an error to the Log<br />
     * @param error<br />
     */<br />
    public void WriteError(String error) {<br />
    &nbsp;&nbsp;&nbsp;&nbsp;System.out.println(error);<br />
    }<br />
}</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[JVM stuck Issue]]></title>
			<link>https://techforum.ewon.biz/thread-2789.html</link>
			<pubDate>Thu, 04 Sep 2025 13:11:30 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://techforum.ewon.biz/member.php?action=profile&uid=6439">ZillKhan</a>]]></dc:creator>
			<guid isPermaLink="false">https://techforum.ewon.biz/thread-2789.html</guid>
			<description><![CDATA[I am writing this to get your assistance with an issue I am facing on eWON flexy 203.<br />
The client runs perfectly fine, but after 1 or 2 days (in some cases 3 days), the JVM gets stuck; however, the eWON is still running, as I can see the Tag values are updating, only the JVM gets stuck.<br />
<br />
I have configured watchdog and updated watchdog periodically, and I am expecting that if, for any reason, any code segment gets stuck for more than the configured watchdog timer, the eWON should reboot. <br />
Let me know if you can provide me with any information regarding this issue. Looking forward to hearing from you or working with you to resolve this issue.<br />
<br />
<br />
<br />
Best Regards,<br />
Zill<br />
<hr class="mycode_hr" />
I have uploaded the screenshot of the issue for better understanding.<br />
You can observe the timestamp in real-time logs and the current timestamp of the eWON as the eWON is still running, but the JVM seems to be stuck.<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://techforum.ewon.biz/images/attachtypes/image.png" title="PNG Image" border="0" alt=".png" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=1879" target="_blank" title="">image.png</a> (Size: 75,86 KB / Downloads: 10)
<!-- end: postbit_attachments_attachment -->]]></description>
			<content:encoded><![CDATA[I am writing this to get your assistance with an issue I am facing on eWON flexy 203.<br />
The client runs perfectly fine, but after 1 or 2 days (in some cases 3 days), the JVM gets stuck; however, the eWON is still running, as I can see the Tag values are updating, only the JVM gets stuck.<br />
<br />
I have configured watchdog and updated watchdog periodically, and I am expecting that if, for any reason, any code segment gets stuck for more than the configured watchdog timer, the eWON should reboot. <br />
Let me know if you can provide me with any information regarding this issue. Looking forward to hearing from you or working with you to resolve this issue.<br />
<br />
<br />
<br />
Best Regards,<br />
Zill<br />
<hr class="mycode_hr" />
I have uploaded the screenshot of the issue for better understanding.<br />
You can observe the timestamp in real-time logs and the current timestamp of the eWON as the eWON is still running, but the JVM seems to be stuck.<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://techforum.ewon.biz/images/attachtypes/image.png" title="PNG Image" border="0" alt=".png" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=1879" target="_blank" title="">image.png</a> (Size: 75,86 KB / Downloads: 10)
<!-- end: postbit_attachments_attachment -->]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[List all file name in the dir (Sort by date modification)]]></title>
			<link>https://techforum.ewon.biz/thread-2773.html</link>
			<pubDate>Wed, 30 Jul 2025 15:04:31 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://techforum.ewon.biz/member.php?action=profile&uid=5607">mickaa</a>]]></dc:creator>
			<guid isPermaLink="false">https://techforum.ewon.biz/thread-2773.html</guid>
			<description><![CDATA[Hello,<br />
<br />
I'd like some help sorting a directory's file names by creation date.<br />
<br />
I found this code for Java 1.4 but couldn't adapt it.<br />
<br />
Thank you for your help.<br />
<br />
<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>File directory = new File("c:&#92;&#92;books&#92;&#92;");<br />
    File[] files = directory.listFiles();<br />
    Arrays.sort(files, new Comparator() {<br />
        public int compare(Object o1, Object o2) {<br />
            File a1=(File)o1;<br />
            File a2=(File)o2;<br />
            if (a1.lastModified() &lt; a2.lastModified())<br />
                return -1;<br />
            else if (a1.lastModified() &gt; a2.lastModified())<br />
                return 1;<br />
            else<br />
                return 0;<br />
        }<br />
    });</code></div></div><br />
This script to add sort by date creation (sz_list )<br />
<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>import com.ewon.ewonitf.EvtWebFormListener;<br />
import java.io.PrintStream;<br />
import java.util.Date;<br />
import java.util.Enumeration;<br />
import javax.microedition.io.Connector;<br />
import javax.microedition.io.file.FileConnection;<br />
<br />
<br />
<br />
/*<br />
 * To change this template, choose Tools | Templates<br />
 * and open the template in the editor.<br />
 */<br />
<br />
/**<br />
 * https://stackoverflow.com/questions/72185256/java-1-4-sort-files-recent-latest<br />
 * @author eWonSupport_Adm<br />
 */<br />
public class MyWebFormListener extends EvtWebFormListener <br />
{<br />
<br />
    public void callForm(String FormName) <br />
    {      <br />
         PrintStream ps = new PrintStream(this);<br />
         <br />
         setWebHeader("text/plain");<br />
<br />
// Test 1: List File<br />
         if ("list".equals(FormName)) <br />
         {             <br />
            try<br />
            {<br />
               String FileConnStr = "file:///" + getWebVar("directory","/");<br />
               <br />
               String directoryStr=getWebVar("directory","");<br />
               ps.println("directoryStr: "+directoryStr);<br />
               <br />
               FileConnection fc =  (FileConnection) Connector.open(FileConnStr);<br />
               if (fc.exists() &amp;&amp; fc.isDirectory())<br />
               {<br />
                   Enumeration x = fc.list();<br />
                   FileConnection fc1 = null;<br />
                   String sz_list = "";<br />
                   <br />
                   <br />
                   String orderStr = getWebVar("order","");<br />
                   String typeStr = getWebVar("type","");<br />
                   String lineBreakStr = getWebVar("lineBreak","");<br />
                   String debugStr = getWebVar("debug","");<br />
                   <br />
                   if ("yes".equals(debugStr))<br />
                   {<br />
                &nbsp;&nbsp;&nbsp;&nbsp;   ps.println("orderStr: "+orderStr);<br />
                &nbsp;&nbsp;&nbsp;&nbsp;   ps.println("typeStr: "+typeStr);<br />
                &nbsp;&nbsp;&nbsp;&nbsp;   ps.println("lineBreakStr: "+lineBreakStr);<br />
                   <br />
                &nbsp;&nbsp;&nbsp;&nbsp;   ps.println("=============== Start List =================");<br />
                &nbsp;&nbsp;&nbsp;&nbsp;   ps.println();<br />
                   }<br />
 <br />
                   while(x.hasMoreElements())<br />
                   {<br />
                       String item =  x.nextElement().toString();<br />
                       fc1 =  (FileConnection) Connector.open(FileConnStr+ "/" + item);<br />
                       // http://192.168.0.10/rcgi.bin/jvmForm?formName=list&amp;debug=yes&amp;type=file&amp;lineBreak=yes&amp;order=ascending&amp;directory=/usr<br />
                       <br />
                       <br />
                                          <br />
                       // list file<br />
                       if ("file".equals(typeStr))<br />
                       {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   if (!fc1.isDirectory())  <br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   if ("yes".equals(lineBreakStr))<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   sz_list += "/" + item+ "&#92;n";<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   }<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   else<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   sz_list += "/" + item + ";";<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   }<br />
                       }<br />
                       <br />
<br />
                       Date lastMod = new Date(fc1.lastModified());<br />
<br />
                       // http://192.168.0.10/rcgi.bin/jvmForm?formName=list&amp;debug=yes&amp;type=dir&amp;lineBreak=yes&amp;order=ascending&amp;directory=/usr<br />
                       <br />
                       // list dir<br />
                       if ("dir".equals(typeStr))<br />
                       {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   if (fc1.isDirectory())  <br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   if ("yes".equals(lineBreakStr))<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   sz_list += "/" + item+ "&#92;n";<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   }<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   else<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   sz_list += "/" + item + ";";<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   }<br />
                       }<br />
                       <br />
                       // http://192.168.0.10/rcgi.bin/jvmForm?formName=list&amp;debug=yes&amp;type=dir&amp;lineBreak=yes&amp;order=ascending&amp;directory=/usr<br />
                       <br />
                       // list file &amp; dir<br />
                       if ("all".equals(typeStr))<br />
                       {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   if (fc1.isDirectory())  <br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   if ("yes".equals(lineBreakStr))<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   sz_list += "[d]/" + item + "&#92;n";<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   }<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   else<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   sz_list += "[d]/" + item + ";";<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   }<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   else<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   if ("yes".equals(lineBreakStr))<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   sz_list += "/" + item+ "&#92;n";<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   }<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   else<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   sz_list += "/" + item + ";";<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   }<br />
                       }<br />
                   }<br />
                   ps.print((sz_list));<br />
               }<br />
               else<br />
                   ps.print("DIRECTORY DOES NOT EXIST");<br />
          }<br />
          catch(Exception ex)<br />
          {<br />
              System.out.println("size Command Error: " + ex.getMessage());<br />
              ps.print("list Command Error");<br />
          }  <br />
 <br />
        }<br />
<br />
       <br />
         if ("delete".equals(FormName))<br />
         {<br />
             try<br />
             {<br />
              String FileConnStr = "file:///" + getWebVar("Directory","/");<br />
              String FilenamePattern = getWebVar("FilenamePattern","");<br />
              FileConnection fc =  (FileConnection) Connector.open(FileConnStr);            <br />
              if (fc.exists())<br />
              {<br />
                  <br />
                   Enumeration list=fc.list();  //gives u total files list (files +dir)<br />
                    while(list.hasMoreElements())<br />
                    {<br />
                        String fileName=(String)list.nextElement();<br />
                        FileConnection localfile=(FileConnection)Connector.open(FileConnStr + "/"+fileName,Connector.READ_WRITE);<br />
                        <br />
                            if(localfile.exists())<br />
                            {<br />
                                if ("".equals(FilenamePattern))<br />
                                    localfile.delete();<br />
                                else<br />
                                    if (fileName.indexOf(FilenamePattern) != -1)<br />
                                        localfile.delete();                                         <br />
                            }<br />
                        }<br />
                    if ("".equals(FilenamePattern))  <br />
                        fc.delete();//Delete the Directory               <br />
                    <br />
                  ps.print(("OK"));<br />
              }<br />
              else<br />
                ps.print("FILE/DIRECTORY DOES NOT EXIST");<br />
                                 <br />
            }<br />
            catch(Exception ex)<br />
            {<br />
               System.out.println("size Command Error: " + ex.getMessage());<br />
               ps.print("delete Command Error" );<br />
            }  <br />
         }<br />
         <br />
         <br />
         <br />
         if ("ftpdelete".equals(FormName))<br />
         {<br />
            try<br />
            {<br />
                ftpClass ftpClient = null;                <br />
                <br />
                String ftpHost = getWebVar("ftpHost","");<br />
                int ftpPort = Integer.parseInt(getWebVar("ftpPort",""));<br />
                String ftpUser = getWebVar("ftpUser","");<br />
                String ftpPassWord = getWebVar("ftpPassword","");<br />
                String ftp_UseRealIpForData = getWebVar("UseRealIp","false");<br />
                String ftp_Debug = getWebVar("Debug","0");<br />
                String ftp_FileDir = getWebVar("FileDir","&#92;&#92;");<br />
                String ftp_FileToDel = getWebVar("FileToDelete","");<br />
                  <br />
                try<br />
                {<br />
                    ftpClient = new ftpClass(ftpHost,ftpPort,ftpUser,ftpPassWord,ftp_UseRealIpForData,ftp_Debug);<br />
                    ftpClient.cwd(ftp_FileDir);<br />
                    ftpClient.dele(ftp_FileToDel);<br />
                    ps.print("ftpdelete Command OK");<br />
                }<br />
                catch(Exception ex)<br />
                {<br />
                    System.out.println("ftpdelete Command Error: " + ex.getMessage());<br />
                    ps.print("ftpdelete Command Error");<br />
                }<br />
                finally<br />
                {<br />
                    if (ftpClient != null) ftpClient.disconnect();<br />
                }<br />
                <br />
                <br />
            }<br />
            catch(Exception ex)<br />
            {<br />
               System.out.println("ftpdelete Command Error: " + ex.getMessage());<br />
               ps.print("ftpdelete Command Error" );<br />
            }  <br />
         }<br />
<br />
    }<br />
}</code></div></div>]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
I'd like some help sorting a directory's file names by creation date.<br />
<br />
I found this code for Java 1.4 but couldn't adapt it.<br />
<br />
Thank you for your help.<br />
<br />
<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>File directory = new File("c:&#92;&#92;books&#92;&#92;");<br />
    File[] files = directory.listFiles();<br />
    Arrays.sort(files, new Comparator() {<br />
        public int compare(Object o1, Object o2) {<br />
            File a1=(File)o1;<br />
            File a2=(File)o2;<br />
            if (a1.lastModified() &lt; a2.lastModified())<br />
                return -1;<br />
            else if (a1.lastModified() &gt; a2.lastModified())<br />
                return 1;<br />
            else<br />
                return 0;<br />
        }<br />
    });</code></div></div><br />
This script to add sort by date creation (sz_list )<br />
<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>import com.ewon.ewonitf.EvtWebFormListener;<br />
import java.io.PrintStream;<br />
import java.util.Date;<br />
import java.util.Enumeration;<br />
import javax.microedition.io.Connector;<br />
import javax.microedition.io.file.FileConnection;<br />
<br />
<br />
<br />
/*<br />
 * To change this template, choose Tools | Templates<br />
 * and open the template in the editor.<br />
 */<br />
<br />
/**<br />
 * https://stackoverflow.com/questions/72185256/java-1-4-sort-files-recent-latest<br />
 * @author eWonSupport_Adm<br />
 */<br />
public class MyWebFormListener extends EvtWebFormListener <br />
{<br />
<br />
    public void callForm(String FormName) <br />
    {      <br />
         PrintStream ps = new PrintStream(this);<br />
         <br />
         setWebHeader("text/plain");<br />
<br />
// Test 1: List File<br />
         if ("list".equals(FormName)) <br />
         {             <br />
            try<br />
            {<br />
               String FileConnStr = "file:///" + getWebVar("directory","/");<br />
               <br />
               String directoryStr=getWebVar("directory","");<br />
               ps.println("directoryStr: "+directoryStr);<br />
               <br />
               FileConnection fc =  (FileConnection) Connector.open(FileConnStr);<br />
               if (fc.exists() &amp;&amp; fc.isDirectory())<br />
               {<br />
                   Enumeration x = fc.list();<br />
                   FileConnection fc1 = null;<br />
                   String sz_list = "";<br />
                   <br />
                   <br />
                   String orderStr = getWebVar("order","");<br />
                   String typeStr = getWebVar("type","");<br />
                   String lineBreakStr = getWebVar("lineBreak","");<br />
                   String debugStr = getWebVar("debug","");<br />
                   <br />
                   if ("yes".equals(debugStr))<br />
                   {<br />
                &nbsp;&nbsp;&nbsp;&nbsp;   ps.println("orderStr: "+orderStr);<br />
                &nbsp;&nbsp;&nbsp;&nbsp;   ps.println("typeStr: "+typeStr);<br />
                &nbsp;&nbsp;&nbsp;&nbsp;   ps.println("lineBreakStr: "+lineBreakStr);<br />
                   <br />
                &nbsp;&nbsp;&nbsp;&nbsp;   ps.println("=============== Start List =================");<br />
                &nbsp;&nbsp;&nbsp;&nbsp;   ps.println();<br />
                   }<br />
 <br />
                   while(x.hasMoreElements())<br />
                   {<br />
                       String item =  x.nextElement().toString();<br />
                       fc1 =  (FileConnection) Connector.open(FileConnStr+ "/" + item);<br />
                       // http://192.168.0.10/rcgi.bin/jvmForm?formName=list&amp;debug=yes&amp;type=file&amp;lineBreak=yes&amp;order=ascending&amp;directory=/usr<br />
                       <br />
                       <br />
                                          <br />
                       // list file<br />
                       if ("file".equals(typeStr))<br />
                       {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   if (!fc1.isDirectory())  <br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   if ("yes".equals(lineBreakStr))<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   sz_list += "/" + item+ "&#92;n";<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   }<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   else<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   sz_list += "/" + item + ";";<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   }<br />
                       }<br />
                       <br />
<br />
                       Date lastMod = new Date(fc1.lastModified());<br />
<br />
                       // http://192.168.0.10/rcgi.bin/jvmForm?formName=list&amp;debug=yes&amp;type=dir&amp;lineBreak=yes&amp;order=ascending&amp;directory=/usr<br />
                       <br />
                       // list dir<br />
                       if ("dir".equals(typeStr))<br />
                       {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   if (fc1.isDirectory())  <br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   if ("yes".equals(lineBreakStr))<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   sz_list += "/" + item+ "&#92;n";<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   }<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   else<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   sz_list += "/" + item + ";";<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   }<br />
                       }<br />
                       <br />
                       // http://192.168.0.10/rcgi.bin/jvmForm?formName=list&amp;debug=yes&amp;type=dir&amp;lineBreak=yes&amp;order=ascending&amp;directory=/usr<br />
                       <br />
                       // list file &amp; dir<br />
                       if ("all".equals(typeStr))<br />
                       {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   if (fc1.isDirectory())  <br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   if ("yes".equals(lineBreakStr))<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   sz_list += "[d]/" + item + "&#92;n";<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   }<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   else<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   sz_list += "[d]/" + item + ";";<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   }<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   else<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   if ("yes".equals(lineBreakStr))<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   {<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   sz_list += "/" + item+ "&#92;n";<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   }<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   else<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   sz_list += "/" + item + ";";<br />
                    &nbsp;&nbsp;&nbsp;&nbsp;   }<br />
                       }<br />
                   }<br />
                   ps.print((sz_list));<br />
               }<br />
               else<br />
                   ps.print("DIRECTORY DOES NOT EXIST");<br />
          }<br />
          catch(Exception ex)<br />
          {<br />
              System.out.println("size Command Error: " + ex.getMessage());<br />
              ps.print("list Command Error");<br />
          }  <br />
 <br />
        }<br />
<br />
       <br />
         if ("delete".equals(FormName))<br />
         {<br />
             try<br />
             {<br />
              String FileConnStr = "file:///" + getWebVar("Directory","/");<br />
              String FilenamePattern = getWebVar("FilenamePattern","");<br />
              FileConnection fc =  (FileConnection) Connector.open(FileConnStr);            <br />
              if (fc.exists())<br />
              {<br />
                  <br />
                   Enumeration list=fc.list();  //gives u total files list (files +dir)<br />
                    while(list.hasMoreElements())<br />
                    {<br />
                        String fileName=(String)list.nextElement();<br />
                        FileConnection localfile=(FileConnection)Connector.open(FileConnStr + "/"+fileName,Connector.READ_WRITE);<br />
                        <br />
                            if(localfile.exists())<br />
                            {<br />
                                if ("".equals(FilenamePattern))<br />
                                    localfile.delete();<br />
                                else<br />
                                    if (fileName.indexOf(FilenamePattern) != -1)<br />
                                        localfile.delete();                                         <br />
                            }<br />
                        }<br />
                    if ("".equals(FilenamePattern))  <br />
                        fc.delete();//Delete the Directory               <br />
                    <br />
                  ps.print(("OK"));<br />
              }<br />
              else<br />
                ps.print("FILE/DIRECTORY DOES NOT EXIST");<br />
                                 <br />
            }<br />
            catch(Exception ex)<br />
            {<br />
               System.out.println("size Command Error: " + ex.getMessage());<br />
               ps.print("delete Command Error" );<br />
            }  <br />
         }<br />
         <br />
         <br />
         <br />
         if ("ftpdelete".equals(FormName))<br />
         {<br />
            try<br />
            {<br />
                ftpClass ftpClient = null;                <br />
                <br />
                String ftpHost = getWebVar("ftpHost","");<br />
                int ftpPort = Integer.parseInt(getWebVar("ftpPort",""));<br />
                String ftpUser = getWebVar("ftpUser","");<br />
                String ftpPassWord = getWebVar("ftpPassword","");<br />
                String ftp_UseRealIpForData = getWebVar("UseRealIp","false");<br />
                String ftp_Debug = getWebVar("Debug","0");<br />
                String ftp_FileDir = getWebVar("FileDir","&#92;&#92;");<br />
                String ftp_FileToDel = getWebVar("FileToDelete","");<br />
                  <br />
                try<br />
                {<br />
                    ftpClient = new ftpClass(ftpHost,ftpPort,ftpUser,ftpPassWord,ftp_UseRealIpForData,ftp_Debug);<br />
                    ftpClient.cwd(ftp_FileDir);<br />
                    ftpClient.dele(ftp_FileToDel);<br />
                    ps.print("ftpdelete Command OK");<br />
                }<br />
                catch(Exception ex)<br />
                {<br />
                    System.out.println("ftpdelete Command Error: " + ex.getMessage());<br />
                    ps.print("ftpdelete Command Error");<br />
                }<br />
                finally<br />
                {<br />
                    if (ftpClient != null) ftpClient.disconnect();<br />
                }<br />
                <br />
                <br />
            }<br />
            catch(Exception ex)<br />
            {<br />
               System.out.println("ftpdelete Command Error: " + ex.getMessage());<br />
               ps.print("ftpdelete Command Error" );<br />
            }  <br />
         }<br />
<br />
    }<br />
}</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Default Event Handler]]></title>
			<link>https://techforum.ewon.biz/thread-2754.html</link>
			<pubDate>Wed, 11 Jun 2025 12:44:51 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://techforum.ewon.biz/member.php?action=profile&uid=6439">ZillKhan</a>]]></dc:creator>
			<guid isPermaLink="false">https://techforum.ewon.biz/thread-2754.html</guid>
			<description><![CDATA[Hello,<br />
I wanted to ask, do you have any specific events that are already defined in default event handler or can we define a custom event handler of our own too?<br />
As mentioned in the Java interface documentation:<br />
" As you can see a “listener” is an instance of a “listener” class, this “listener” class derive from the EvtListenerBase object and defines the callEvent function, this function will be called when the runEventHandler will detect the specific type of event"]]></description>
			<content:encoded><![CDATA[Hello,<br />
I wanted to ask, do you have any specific events that are already defined in default event handler or can we define a custom event handler of our own too?<br />
As mentioned in the Java interface documentation:<br />
" As you can see a “listener” is an instance of a “listener” class, this “listener” class derive from the EvtListenerBase object and defines the callEvent function, this function will be called when the runEventHandler will detect the specific type of event"]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[RuntimeControl.refreshWatchdog() understanding]]></title>
			<link>https://techforum.ewon.biz/thread-2752.html</link>
			<pubDate>Mon, 02 Jun 2025 11:45:29 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://techforum.ewon.biz/member.php?action=profile&uid=6439">ZillKhan</a>]]></dc:creator>
			<guid isPermaLink="false">https://techforum.ewon.biz/thread-2752.html</guid>
			<description><![CDATA[Hello,<br />
I want to understand the working of <span style="color: #cccccc;" class="mycode_color"><span style="font-family: Consolas, 'Courier New', monospace;" class="mycode_font"><span style="color: #9cdcfe;" class="mycode_color">RuntimeControl</span><span style="color: #cccccc;" class="mycode_color">.</span><span style="color: #dcdcaa;" class="mycode_color">refreshWatchdog</span><span style="color: #cccccc;" class="mycode_color">();</span></span></span><br />
I am using Java to program eWON for my application.<br />
In my Java client application I set the watchdog timeout using this:<br />
<span style="color: #cccccc;" class="mycode_color"><span style="font-family: Consolas, 'Courier New', monospace;" class="mycode_font"><span style="color: #9cdcfe;" class="mycode_color">RuntimeControl</span><span style="color: #cccccc;" class="mycode_color">.</span><span style="color: #dcdcaa;" class="mycode_color">configureAppWatchdog</span><span style="color: #cccccc;" class="mycode_color">(</span><span style="color: #b5cea8;" class="mycode_color">60000</span><span style="color: #cccccc;" class="mycode_color">); // timeout set to 60sec - assuming its timeout is in milisecond</span></span></span><br />
<br />
<span style="color: #cccccc;" class="mycode_color"><span style="font-family: Consolas, Courier New, monospace;" class="mycode_font">Then, in my application while loop, I run this every 30 seconds.<br />
<span style="color: #cccccc;" class="mycode_color">[font=Consolas, 'Courier New', monospace]<span style="color: #c586c0;" class="mycode_color">if</span><span style="color: #cccccc;" class="mycode_color"> (</span><span style="color: #9cdcfe;" class="mycode_color">currentTime</span> <span style="color: #d4d4d4;" class="mycode_color">-</span> <span style="color: #9cdcfe;" class="mycode_color">startTime</span> <span style="color: #d4d4d4;" class="mycode_color">&gt;=</span> <span style="color: #4fc1ff;" class="mycode_color">RESTART_TIME_THRESHOLD</span><span style="color: #cccccc;" class="mycode_color">) {</span><br />
<span style="color: #cccccc;" class="mycode_color">                </span><span style="color: #4ec9b0;" class="mycode_color">Log</span><span style="color: #cccccc;" class="mycode_color">.</span><span style="color: #dcdcaa;" class="mycode_color">info</span><span style="color: #cccccc;" class="mycode_color">(</span><span style="color: #ce9178;" class="mycode_color">"Refreshing Watchdog timer!"</span><span style="color: #cccccc;" class="mycode_color">);</span><br />
<span style="color: #cccccc;" class="mycode_color">                </span><span style="color: #9cdcfe;" class="mycode_color">RuntimeControl</span><span style="color: #cccccc;" class="mycode_color">.</span><span style="color: #dcdcaa;" class="mycode_color">refreshWatchdog</span><span style="color: #cccccc;" class="mycode_color">();</span><br />
<span style="color: #cccccc;" class="mycode_color">                </span><span style="color: #9cdcfe;" class="mycode_color">startTime</span> <span style="color: #d4d4d4;" class="mycode_color">=</span> <span style="color: #9cdcfe;" class="mycode_color">currentTime</span><span style="color: #cccccc;" class="mycode_color">;</span><br />
<span style="color: #cccccc;" class="mycode_color">            }</span></span></span>[/font]</span><br />
<br />
<span style="font-family: Consolas, Courier New, monospace;" class="mycode_font"><span style="color: #000000;" class="mycode_color">Can you please confirm it's working and also provide any reference documentation for looking into this API in detail.</span><br />
<br />
<br />
</span>]]></description>
			<content:encoded><![CDATA[Hello,<br />
I want to understand the working of <span style="color: #cccccc;" class="mycode_color"><span style="font-family: Consolas, 'Courier New', monospace;" class="mycode_font"><span style="color: #9cdcfe;" class="mycode_color">RuntimeControl</span><span style="color: #cccccc;" class="mycode_color">.</span><span style="color: #dcdcaa;" class="mycode_color">refreshWatchdog</span><span style="color: #cccccc;" class="mycode_color">();</span></span></span><br />
I am using Java to program eWON for my application.<br />
In my Java client application I set the watchdog timeout using this:<br />
<span style="color: #cccccc;" class="mycode_color"><span style="font-family: Consolas, 'Courier New', monospace;" class="mycode_font"><span style="color: #9cdcfe;" class="mycode_color">RuntimeControl</span><span style="color: #cccccc;" class="mycode_color">.</span><span style="color: #dcdcaa;" class="mycode_color">configureAppWatchdog</span><span style="color: #cccccc;" class="mycode_color">(</span><span style="color: #b5cea8;" class="mycode_color">60000</span><span style="color: #cccccc;" class="mycode_color">); // timeout set to 60sec - assuming its timeout is in milisecond</span></span></span><br />
<br />
<span style="color: #cccccc;" class="mycode_color"><span style="font-family: Consolas, Courier New, monospace;" class="mycode_font">Then, in my application while loop, I run this every 30 seconds.<br />
<span style="color: #cccccc;" class="mycode_color">[font=Consolas, 'Courier New', monospace]<span style="color: #c586c0;" class="mycode_color">if</span><span style="color: #cccccc;" class="mycode_color"> (</span><span style="color: #9cdcfe;" class="mycode_color">currentTime</span> <span style="color: #d4d4d4;" class="mycode_color">-</span> <span style="color: #9cdcfe;" class="mycode_color">startTime</span> <span style="color: #d4d4d4;" class="mycode_color">&gt;=</span> <span style="color: #4fc1ff;" class="mycode_color">RESTART_TIME_THRESHOLD</span><span style="color: #cccccc;" class="mycode_color">) {</span><br />
<span style="color: #cccccc;" class="mycode_color">                </span><span style="color: #4ec9b0;" class="mycode_color">Log</span><span style="color: #cccccc;" class="mycode_color">.</span><span style="color: #dcdcaa;" class="mycode_color">info</span><span style="color: #cccccc;" class="mycode_color">(</span><span style="color: #ce9178;" class="mycode_color">"Refreshing Watchdog timer!"</span><span style="color: #cccccc;" class="mycode_color">);</span><br />
<span style="color: #cccccc;" class="mycode_color">                </span><span style="color: #9cdcfe;" class="mycode_color">RuntimeControl</span><span style="color: #cccccc;" class="mycode_color">.</span><span style="color: #dcdcaa;" class="mycode_color">refreshWatchdog</span><span style="color: #cccccc;" class="mycode_color">();</span><br />
<span style="color: #cccccc;" class="mycode_color">                </span><span style="color: #9cdcfe;" class="mycode_color">startTime</span> <span style="color: #d4d4d4;" class="mycode_color">=</span> <span style="color: #9cdcfe;" class="mycode_color">currentTime</span><span style="color: #cccccc;" class="mycode_color">;</span><br />
<span style="color: #cccccc;" class="mycode_color">            }</span></span></span>[/font]</span><br />
<br />
<span style="font-family: Consolas, Courier New, monospace;" class="mycode_font"><span style="color: #000000;" class="mycode_color">Can you please confirm it's working and also provide any reference documentation for looking into this API in detail.</span><br />
<br />
<br />
</span>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Breaking a line of code into two or more lines]]></title>
			<link>https://techforum.ewon.biz/thread-2726.html</link>
			<pubDate>Thu, 27 Feb 2025 18:28:04 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://techforum.ewon.biz/member.php?action=profile&uid=6223">Liberty</a>]]></dc:creator>
			<guid isPermaLink="false">https://techforum.ewon.biz/thread-2726.html</guid>
			<description><![CDATA[Hello people. Please help me in breaking a line of code in BASIC IDE and continuing it in the next line to avoid the error message shown in the attached image.]]></description>
			<content:encoded><![CDATA[Hello people. Please help me in breaking a line of code in BASIC IDE and continuing it in the next line to avoid the error message shown in the attached image.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[JVM Errors MQTT I/O Server]]></title>
			<link>https://techforum.ewon.biz/thread-2713.html</link>
			<pubDate>Tue, 04 Feb 2025 21:57:41 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://techforum.ewon.biz/member.php?action=profile&uid=4823">berntjb</a>]]></dc:creator>
			<guid isPermaLink="false">https://techforum.ewon.biz/thread-2713.html</guid>
			<description><![CDATA[Hello<br />
<br />
I've written an IO-Server that publishes tags over MQTT. I've had this installed on my Flexy 205 for 3 years now without any problems.<br />
Today I installed it on a Flexy 201 with newer fw 19 vs 16, and I'm getting some weird errors.<br />
<br />
Firstly I wasn't able to write new config using the textbox field in the IO-Server list. It just gave me an error saying "Board does not exists".<br />
Then I added the config directly through the Setup - System - Storage - Edit System cfg and rebooted the unit.<br />
It then picked up the config and connected to the MQTT broker and keeps pushing values... until it doesn't. It disconnects without any errors.<br />
<br />
But I keep seeing this in the logs, not sure if it's related:<br />
<br />
 <br />
Time                           Source        Event                                                                                                                      Clock  EventID<br />
04/02/2025 22:00:55    JVM            ABORT Wonka: tryPutFifo 655: Could not push [B@0x0070e1e8 onto fifo 0x0044e8f8!    210793  28<br />
04/02/2025 22:00:55    JVM                                                                                                                                          210793  27<br />
04/02/2025 22:00:55    JVM            Failed to allocate 4096 bytes                                                                                      210792  26<br />
<br />
<br />
The IO-server.jar was build 3 years ago. <br />
<br />
Here are the docs I've made for the installation:<br />
<a href="https://docs.clarify.io/developers/hardware/ewon-flexy" target="_blank" rel="noopener" class="mycode_url">https://docs.clarify.io/developers/hardware/ewon-flexy</a><br />
<br />
Looking forward to any help ?]]></description>
			<content:encoded><![CDATA[Hello<br />
<br />
I've written an IO-Server that publishes tags over MQTT. I've had this installed on my Flexy 205 for 3 years now without any problems.<br />
Today I installed it on a Flexy 201 with newer fw 19 vs 16, and I'm getting some weird errors.<br />
<br />
Firstly I wasn't able to write new config using the textbox field in the IO-Server list. It just gave me an error saying "Board does not exists".<br />
Then I added the config directly through the Setup - System - Storage - Edit System cfg and rebooted the unit.<br />
It then picked up the config and connected to the MQTT broker and keeps pushing values... until it doesn't. It disconnects without any errors.<br />
<br />
But I keep seeing this in the logs, not sure if it's related:<br />
<br />
 <br />
Time                           Source        Event                                                                                                                      Clock  EventID<br />
04/02/2025 22:00:55    JVM            ABORT Wonka: tryPutFifo 655: Could not push [B@0x0070e1e8 onto fifo 0x0044e8f8!    210793  28<br />
04/02/2025 22:00:55    JVM                                                                                                                                          210793  27<br />
04/02/2025 22:00:55    JVM            Failed to allocate 4096 bytes                                                                                      210792  26<br />
<br />
<br />
The IO-server.jar was build 3 years ago. <br />
<br />
Here are the docs I've made for the installation:<br />
<a href="https://docs.clarify.io/developers/hardware/ewon-flexy" target="_blank" rel="noopener" class="mycode_url">https://docs.clarify.io/developers/hardware/ewon-flexy</a><br />
<br />
Looking forward to any help ?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Update IOServer Datas]]></title>
			<link>https://techforum.ewon.biz/thread-2701.html</link>
			<pubDate>Fri, 17 Jan 2025 14:41:42 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://techforum.ewon.biz/member.php?action=profile&uid=1946">Alexandre Bouteiller</a>]]></dc:creator>
			<guid isPermaLink="false">https://techforum.ewon.biz/thread-2701.html</guid>
			<description><![CDATA[Hi everyone,<br />
<br />
With My Java application I am using the com.ewon.ewonitf.IOServer library in order to read config parameters, thanks to getConfigParam() method.<br />
<br />
I was wondering if there was a way to update values with com.ewon.ewonitf.IOServer library ?<br />
<br />
Best regards<br />
<br />
Alexandre]]></description>
			<content:encoded><![CDATA[Hi everyone,<br />
<br />
With My Java application I am using the com.ewon.ewonitf.IOServer library in order to read config parameters, thanks to getConfigParam() method.<br />
<br />
I was wondering if there was a way to update values with com.ewon.ewonitf.IOServer library ?<br />
<br />
Best regards<br />
<br />
Alexandre]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Error setting up Java IOServer]]></title>
			<link>https://techforum.ewon.biz/thread-2574.html</link>
			<pubDate>Tue, 24 Sep 2024 06:04:30 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://techforum.ewon.biz/member.php?action=profile&uid=4370">Manuele</a>]]></dc:creator>
			<guid isPermaLink="false">https://techforum.ewon.biz/thread-2574.html</guid>
			<description><![CDATA[Hello,<br />
I am trying to get multiple IOServers up and running on an eWon Flexy, however I am running into some difficulties:<br />
<br />
I am setting up the servers as follows<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>List servers = new ArrayList();<br />
<br />
// For testing purposes, this only has 1 server statically generated<br />
servers.add(new MyIOServer());<br />
<br />
Iterator it = servers.iterator();<br />
while(it.hasNext()) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;IOServerImpl server = it.next();<br />
&nbsp;&nbsp;&nbsp;&nbsp;Thread serverThread = new Thread(server);<br />
&nbsp;&nbsp;&nbsp;&nbsp;try {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server.registerServer();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;serverThread.start();<br />
&nbsp;&nbsp;&nbsp;&nbsp;} catch (Exception e) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(e.toString());<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}</code></div></div><br />
<br />
And I am calling the "runEventManager" function <span style="font-style: italic;" class="mycode_i">after</span> I finish setting up the servers<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>DefaultEventHandler.runEventManager()</code></div></div><br />
1) If I try to send the JAR file to the eWon via FTP (along with the "jvmrun" file), the server does not appear on the IO Server list. If on the other hand I setup the "build.xml" to automatically push the JAR file when building, then the server shows up on the list.<br />
2) If I try to edit the configuration of the new IO Server, I get the error "ERROR: Board does not exist".<br />
3) If I reboot the device, the server is deleted from the list, which means that I have to re-build the solution to have the server show up on the page again.<br />
<br />
What's weird is that from the Realtime Logs, everything seems to be working as expected. In the Event Logs I sometimes see the error "jio-IO Server is not ready". Did I make a mistake setting up the server?<br />
<br />
Thanks]]></description>
			<content:encoded><![CDATA[Hello,<br />
I am trying to get multiple IOServers up and running on an eWon Flexy, however I am running into some difficulties:<br />
<br />
I am setting up the servers as follows<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>List servers = new ArrayList();<br />
<br />
// For testing purposes, this only has 1 server statically generated<br />
servers.add(new MyIOServer());<br />
<br />
Iterator it = servers.iterator();<br />
while(it.hasNext()) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;IOServerImpl server = it.next();<br />
&nbsp;&nbsp;&nbsp;&nbsp;Thread serverThread = new Thread(server);<br />
&nbsp;&nbsp;&nbsp;&nbsp;try {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server.registerServer();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;serverThread.start();<br />
&nbsp;&nbsp;&nbsp;&nbsp;} catch (Exception e) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(e.toString());<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}</code></div></div><br />
<br />
And I am calling the "runEventManager" function <span style="font-style: italic;" class="mycode_i">after</span> I finish setting up the servers<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>DefaultEventHandler.runEventManager()</code></div></div><br />
1) If I try to send the JAR file to the eWon via FTP (along with the "jvmrun" file), the server does not appear on the IO Server list. If on the other hand I setup the "build.xml" to automatically push the JAR file when building, then the server shows up on the list.<br />
2) If I try to edit the configuration of the new IO Server, I get the error "ERROR: Board does not exist".<br />
3) If I reboot the device, the server is deleted from the list, which means that I have to re-build the solution to have the server show up on the page again.<br />
<br />
What's weird is that from the Realtime Logs, everything seems to be working as expected. In the Event Logs I sometimes see the error "jio-IO Server is not ready". Did I make a mistake setting up the server?<br />
<br />
Thanks]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[MQTT tls url check]]></title>
			<link>https://techforum.ewon.biz/thread-2526.html</link>
			<pubDate>Wed, 19 Jun 2024 09:03:16 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://techforum.ewon.biz/member.php?action=profile&uid=3567">davide</a>]]></dc:creator>
			<guid isPermaLink="false">https://techforum.ewon.biz/thread-2526.html</guid>
			<description><![CDATA[Hi, <br />
I have an eWON where I implemented an MQTT client using the Java SDK javaetk_1.4.4, utilizing TLS encryption. <br />
<br />
The problem is that the URL I specify when instantiating the MQTT client is different from the URL present in the TLS certificate, and thus the eWON is unable to connect. <br />
<br />
Searching online, I found that in other libraries it is possible to disable this check, and I wanted to know if there is a parameter I can provide to the "setOption" function to disable this check.<br />
<br />
Thank you.]]></description>
			<content:encoded><![CDATA[Hi, <br />
I have an eWON where I implemented an MQTT client using the Java SDK javaetk_1.4.4, utilizing TLS encryption. <br />
<br />
The problem is that the URL I specify when instantiating the MQTT client is different from the URL present in the TLS certificate, and thus the eWON is unable to connect. <br />
<br />
Searching online, I found that in other libraries it is possible to disable this check, and I wanted to know if there is a parameter I can provide to the "setOption" function to disable this check.<br />
<br />
Thank you.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Create Tag for MODBUS via com.ewon.ewonitf]]></title>
			<link>https://techforum.ewon.biz/thread-2450.html</link>
			<pubDate>Fri, 16 Feb 2024 12:13:36 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://techforum.ewon.biz/member.php?action=profile&uid=5575">attila.katona</a>]]></dc:creator>
			<guid isPermaLink="false">https://techforum.ewon.biz/thread-2450.html</guid>
			<description><![CDATA[Hi,<br />
<br />
I would create tags for "MODBUS" IO server in JAVA via the classes available in com.ewon.ewonitf package. I guess it could be done as following:<br />
<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>SysControlBlock tagSysControlBlock = new SysControlBlock(SysControlBlock.TAG);<br />
<br />
tagSysControlBlock.setItem(TAG_NAME_KEY, tagName);<br />
tagSysControlBlock.setItem(TAG_SERVER_NAME_KEY, ioServerName);<br />
tagSysControlBlock.setItem(TAG_ADDRESS_KEY, ioAddress);<br />
tagSysControlBlock.setItem(TAG_TYPE_KEY, String.valueOf(tagType));<br />
<br />
<br />
tagSysControlBlock.saveBlock(true);</code></div></div><br />
<br />
Would it be a viable way to create tags for "MODBUS" IO server programmatically via JAVA from your perspective?<br />
<br />
There is also a class SCTagUtils in the package com.hms_networks.americas.sc.extensions.system.tags, however it only supports "MEM" IO server and I guess it is not tended to be extended with some extra functionalities.<br />
<br />
Thank you!<br />
Best regards,<br />
Attila]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
I would create tags for "MODBUS" IO server in JAVA via the classes available in com.ewon.ewonitf package. I guess it could be done as following:<br />
<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>SysControlBlock tagSysControlBlock = new SysControlBlock(SysControlBlock.TAG);<br />
<br />
tagSysControlBlock.setItem(TAG_NAME_KEY, tagName);<br />
tagSysControlBlock.setItem(TAG_SERVER_NAME_KEY, ioServerName);<br />
tagSysControlBlock.setItem(TAG_ADDRESS_KEY, ioAddress);<br />
tagSysControlBlock.setItem(TAG_TYPE_KEY, String.valueOf(tagType));<br />
<br />
<br />
tagSysControlBlock.saveBlock(true);</code></div></div><br />
<br />
Would it be a viable way to create tags for "MODBUS" IO server programmatically via JAVA from your perspective?<br />
<br />
There is also a class SCTagUtils in the package com.hms_networks.americas.sc.extensions.system.tags, however it only supports "MEM" IO server and I guess it is not tended to be extended with some extra functionalities.<br />
<br />
Thank you!<br />
Best regards,<br />
Attila]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Tag Unit]]></title>
			<link>https://techforum.ewon.biz/thread-2447.html</link>
			<pubDate>Wed, 07 Feb 2024 02:27:02 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://techforum.ewon.biz/member.php?action=profile&uid=5424">ryanstandeven</a>]]></dc:creator>
			<guid isPermaLink="false">https://techforum.ewon.biz/thread-2447.html</guid>
			<description><![CDATA[Is there a way to get the unit information for a Tag without having to parse the whole var_lst?<br />
<br />
I was really hoping that TagControl had something I could use but it doesn't look to be the case.]]></description>
			<content:encoded><![CDATA[Is there a way to get the unit information for a Tag without having to parse the whole var_lst?<br />
<br />
I was really hoping that TagControl had something I could use but it doesn't look to be the case.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Azure Event Hubs, SAS Token]]></title>
			<link>https://techforum.ewon.biz/thread-2445.html</link>
			<pubDate>Tue, 30 Jan 2024 16:01:34 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://techforum.ewon.biz/member.php?action=profile&uid=153">dmned</a>]]></dc:creator>
			<guid isPermaLink="false">https://techforum.ewon.biz/thread-2445.html</guid>
			<description><![CDATA[From this <a href="https://techforum.ewon.biz/thread-939.html?highlight=azure+java" target="_blank" rel="noopener" class="mycode_url">post</a> I see connections may be established to Azure using a certificate. I have need to make a connection by requesting and receiving a SAS token from Azure, then using the token for authorization to post a JSON packet to an Azure Event Hub. I have successfully tested these steps in the Postman app, which first runs a script to request and receive the SAS token, then passes the received token in the authorization header for the API call to POST the JSON packet. Thus far I have not found a Flexy BASIC or JAVA script example, or been able to develop one, which mimics the token request/receive/pass step.<br />
<br />
Is it possible to request/receive/pass a SAS token in BASIC or JAVA and, if so, how?<br />
<br />
Below is the script from Postman which requests, receives and passes the token to the API call. The specific namespace, key name, key name, etc. variable values to initiate the steps are part of the Postman workspace, allowing the process to result in the received token. I haven't tried using this script on the Flexy, mainly because I'm not sure how to monitor or debug it to see where it would likely malfunction.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>const servicebusNamespace = pm.variables.get("servicebusNamespace");<br />
const namespaceUri = "https://"+servicebusNamespace+".servicebus.windows.net";<br />
const sasKeyName = pm.variables.get("sasKeyName");<br />
const sasKey = pm.variables.get("sasKey");<br />
const sasToken = createServiceBusOrEventHubsSASToken(namespaceUri, sasKeyName, sasKey);<br />
pm.variables.set("sasToken", sasToken);<br />
pm.variables.set("sasTokenView",sasToken);<br />
<br />
/**<br />
 * Create a Shared Access Signature (SAS) token valid for one minute for use with the Azure Service Bus or Event Hubs REST APIs<br />
 * Based on https://docs.microsoft.com/en-us/rest/api/eventhub/generate-sas-token but modified to use crypto-js for compatibility with Postman<br />
 * @param resourceUri - The full uri of the resource, e.g. https://&lt;yournamespace&gt;.servicebus.windows.net<br />
 * @param sasKeyName - The name of the Shared Access Signature key<br />
 * @param sasKey - The Shared Access Signature key<br />
 * @returns- A Shared Access Signature token<br />
 * {@link https://github.com/lfalck/AzureRestApiPostmanCollections GitHub}<br />
 * <br />
 */<br />
function createServiceBusOrEventHubsSASToken(resourceUri, sasKeyName, sasKey) {<br />
    if (!resourceUri || !sasKeyName || !sasKey) {<br />
        throw "Missing required parameter";<br />
    }<br />
    const encoded = encodeURIComponent(resourceUri);<br />
    const now = new Date();<br />
    const minute = 60*60*24*7;<br />
    const ttl = Math.round(now.getTime() / 1000) + minute;<br />
    const signature = encoded + '&#92;n' + ttl;<br />
    const hash = CryptoJS.HmacSHA256(signature, sasKey).toString(CryptoJS.enc.Base64);<br />
    return 'SharedAccessSignature sr=' + encoded + '&amp;sig=' +<br />
        encodeURIComponent(hash) + '&amp;se=' + ttl + '&amp;skn=' + sasKeyName;<br />
}</code></div></div>]]></description>
			<content:encoded><![CDATA[From this <a href="https://techforum.ewon.biz/thread-939.html?highlight=azure+java" target="_blank" rel="noopener" class="mycode_url">post</a> I see connections may be established to Azure using a certificate. I have need to make a connection by requesting and receiving a SAS token from Azure, then using the token for authorization to post a JSON packet to an Azure Event Hub. I have successfully tested these steps in the Postman app, which first runs a script to request and receive the SAS token, then passes the received token in the authorization header for the API call to POST the JSON packet. Thus far I have not found a Flexy BASIC or JAVA script example, or been able to develop one, which mimics the token request/receive/pass step.<br />
<br />
Is it possible to request/receive/pass a SAS token in BASIC or JAVA and, if so, how?<br />
<br />
Below is the script from Postman which requests, receives and passes the token to the API call. The specific namespace, key name, key name, etc. variable values to initiate the steps are part of the Postman workspace, allowing the process to result in the received token. I haven't tried using this script on the Flexy, mainly because I'm not sure how to monitor or debug it to see where it would likely malfunction.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>const servicebusNamespace = pm.variables.get("servicebusNamespace");<br />
const namespaceUri = "https://"+servicebusNamespace+".servicebus.windows.net";<br />
const sasKeyName = pm.variables.get("sasKeyName");<br />
const sasKey = pm.variables.get("sasKey");<br />
const sasToken = createServiceBusOrEventHubsSASToken(namespaceUri, sasKeyName, sasKey);<br />
pm.variables.set("sasToken", sasToken);<br />
pm.variables.set("sasTokenView",sasToken);<br />
<br />
/**<br />
 * Create a Shared Access Signature (SAS) token valid for one minute for use with the Azure Service Bus or Event Hubs REST APIs<br />
 * Based on https://docs.microsoft.com/en-us/rest/api/eventhub/generate-sas-token but modified to use crypto-js for compatibility with Postman<br />
 * @param resourceUri - The full uri of the resource, e.g. https://&lt;yournamespace&gt;.servicebus.windows.net<br />
 * @param sasKeyName - The name of the Shared Access Signature key<br />
 * @param sasKey - The Shared Access Signature key<br />
 * @returns- A Shared Access Signature token<br />
 * {@link https://github.com/lfalck/AzureRestApiPostmanCollections GitHub}<br />
 * <br />
 */<br />
function createServiceBusOrEventHubsSASToken(resourceUri, sasKeyName, sasKey) {<br />
    if (!resourceUri || !sasKeyName || !sasKey) {<br />
        throw "Missing required parameter";<br />
    }<br />
    const encoded = encodeURIComponent(resourceUri);<br />
    const now = new Date();<br />
    const minute = 60*60*24*7;<br />
    const ttl = Math.round(now.getTime() / 1000) + minute;<br />
    const signature = encoded + '&#92;n' + ttl;<br />
    const hash = CryptoJS.HmacSHA256(signature, sasKey).toString(CryptoJS.enc.Base64);<br />
    return 'SharedAccessSignature sr=' + encoded + '&amp;sig=' +<br />
        encodeURIComponent(hash) + '&amp;se=' + ttl + '&amp;skn=' + sasKeyName;<br />
}</code></div></div>]]></content:encoded>
		</item>
	</channel>
</rss>