Custom script blocking RMS

Hello,
I have complained about custom scripts blocking rms since version 7.10 and still it is happening. The issue could be resolved using /etc/init.d/rms_mqtt restart, but this time I didn’t use it because on 7.15.1 the issue seemed to be resolved. Now on firmware 7.15.2 the issue is back and I am unable to access my Rut906 that is on the other side of my country.

Will this issue ever be resolved, because it doesn’t look like Teltonika is doing anything to address the issue.

Hello,

Could you kindly elaborate more on your custom script? What does it do exactly, and if you already know the potential cause, what’s the reasoning behind RMS being blocked by it?

You said you have mentioned this previously, do you perhaps have an old thread number I could check to gather more information?

Regards,
M.

Hello,

Here is a link to a previous thread:

Here is the script I am currently using:

!/bin/ash

sleep 30

/etc/init.d/rms_mqtt restart

serial_Nr=$(cat /sys/mnf_info/serial)
BROKER=Broker_IP
PORT=1883
TOPIC=“/${serial_Nr}_WR”
RESPONSE_TOPIC=“/${serial_Nr}_WR/response”
USERNAME=“Username”
PASSWORD=“Password”
QOS=0
RETRY_INTERVAL=10
MAX_RETRIES=10

check_internet() {
ping -c 1 -W 1 8.8.8.8 >/dev/null 2>&1 || curl -s --head --max-time 2 https://www.google.com >/dev/null 2>&1
return $?
}

ensure_package_installed() {
package_name=“$1”
max_retries=5
retry_interval=30
retry_count=0

while true; do
    if opkg list-installed | grep -q "^$package_name "; then
        echo "Package '$package_name' is already installed."
        return 0
    fi

    echo "Checking internet connectivity..."
    while ! check_internet; do
        retry_count=$((retry_count + 1))
        if [ "$retry_count" -ge "$max_retries" ]; then
            echo "No internet connectivity after $max_retries attempts. Exiting for now. Retry later."
            exit 1
        fi
        echo "No internet connection. Retrying in $retry_interval seconds... ($retry_count/$max_retries)"
        sleep "$retry_interval"
    done

    opkg -e /etc/opkg/openwrt/distfeeds.conf update

    echo "Attempting to install package '$package_name'..."
    if opkg -e /etc/opkg/openwrt/distfeeds.conf install "$package_name"; then
        echo "Package '$package_name' installed successfully."
        return 0
    else
        echo "Failed to install package '$package_name'. Retrying in $retry_interval seconds..."
        sleep "$retry_interval"
    fi
done

}

required_packages=“curl coreutils-timeout mosquitto-client-ssl jq”
for package in $required_packages; do
ensure_package_installed “$package”
done

for i in $(seq 1 $MAX_RETRIES); do
echo “Attempting to connect to MQTT broker (Attempt $i)…”

mosquitto_pub -h $BROKER -p $PORT -t "/test/connection" -u $USERNAME -P $PASSWORD -m "test" -q $QOS

if [ $? -eq 0 ]; then
    echo "Connected to MQTT broker successfully."

    mosquitto_sub -h $BROKER -p $PORT -t $TOPIC -u $USERNAME -P $PASSWORD -q $QOS | while read -r message
    do
        echo "Received MQTT message: $message"

        ID=$(echo "$message" | jq -r '.id')
        TIMEOUT=$(echo "$message" | jq -r '.timeout')
        FUNCTION=$(echo "$message" | jq -r '.function')
        FIRST_REG=$(echo "$message" | jq -r '.first_reg')
        REG_COUNT=$(echo "$message" | jq -r '.reg_count')
        DATA_TYPE=$(echo "$message" | jq -r '.data_type')
        NO_BRACKETS=$(echo "$message" | jq -r '.no_brackets')

        RESPONSE=$(ubus call modbus_client.rpc serial.test "{
            \"id\": $ID,
            \"timeout\": $TIMEOUT,
            \"function\": $FUNCTION,
            \"first_reg\": $FIRST_REG,
            \"reg_count\": \"$REG_COUNT\",
            \"data_type\": \"$DATA_TYPE\",
            \"no_brackets\": $NO_BRACKETS,
            \"serial_type\": \"/dev/rs485\",
            \"baudrate\": 9600,
            \"databits\": 8,
            \"stopbits\": 1,
            \"parity\": \"none\",
            \"flowcontrol\": \"none\"
        }")

        echo "Modbus Response: $RESPONSE"
        
        # Publish response to MQTT
        timeout 4 mosquitto_pub -h $BROKER -p $PORT -t "$RESPONSE_TOPIC" -u $USERNAME -P $PASSWORD -m "$RESPONSE" -q $QOS
        
        sleep 1
    done
    break
else
    echo "Failed to connect to MQTT broker. Retrying in $RETRY_INTERVAL seconds..."
    sleep $RETRY_INTERVAL
fi

done

if [ $? -ne 0 ]; then
echo “Failed to connect to MQTT broker after $MAX_RETRIES attempts.”
exit 1
fi

This script works the only difference is on the router that is now blocked from rms I didn’t have the /etc/init.d/rms_mqtt restart. I left this code out because on firmware 7.15.1 it didn’t need it, so I thought the issue was resolved.

I have tried sending sms’s to my router to reconnect to rms, and I have been getting responses saying the command was executed. However the router never tried reconnecting to rms. Also when I send rms_status over sms I get and error saying the command could not be executed.

I am open to any suggestions to fix this issue, because the router is on the other side of my country, and I desperately need to access it.

Hey there,

I’ve reached out to the RMS R&D to ask about this further and will get back to you once I have a response.

Thank you for your patience,
M.

Hi there,

The R&D has requested some more information that is sensitive, therefore I’ve sent you a form to fill out so we can continue our conversation in private, to avoid accidentally leaking that information.. In the Ticket ID field, simply enter the thread’s number, which is 14457.

Thank you,
M.