Community discussions

MikroTik App
 
wojo
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 85
Joined: Tue Aug 21, 2018 4:37 am

Action Timed Out only on startup, not subsequent runs of script

Tue Aug 21, 2018 4:46 am

I get a script error only when running a script during startup. When it runs on a scheduled run after, it is fine. The error is:
script,error router atl: script error: action timed out - try again, if error continues contact MikroTik support and send a supout file (13)
The script is as follows:
:local maticuser "user"
:local maticpass "pass"
:local matichost "host"
:local currentIPFile disk1/dnsomatic-current-ipv4.txt
:local logFile disk1/dnsomatic-log.txt

:global dnsomaticPreviousIP

:log info "DNSoMatic: fetching current IP"

:do {
  /tool fetch url="http://myip.dnsomatic.com/" mode=http dst-path=$currentIPFile
} on-error={ :local error "DNSoMatic: failed to get IP"; :log error $error; :error $error }

:local currentIP [/file get $currentIPFile contents]

:if ($currentIP != $dnsomaticPreviousIP) do={
  :log info "DNSoMatic: new=$currentIP, old=$dnsomaticPreviousIP, trying update"

  :do {
    /tool fetch url="http://updates.dnsomatic.com/nic/update\3Fmyip=$currentIP&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG&hostname=$matichost" user=$maticuser password=$maticpass mode=http dst-path=$logFile
  } on-error={ :local error "DNSoMatic: failed to update"; :log error $error; :error $error }

  :log info ("DNSoMatic: response: " . [/file get $logFile contents])
  :log info "DNSoMatic: new=$currentIP, old=$dnsomaticPreviousIP"
  :set dnsomaticPreviousIP $currentIP
} else={
  :log info "DNSoMatic: no change"
}
This runs on as schedule from startup and every 15 minutes. I've tried a delay of 30s, 5m, etc but it will still error out the first time and only the first time.

It always times out at the fetch line, it does log this right before:
  :log info "DNSoMatic: new=$currentIP, old=$dnsomaticPreviousIP, trying update"
It does not hit my error catch.

Any ideas on how to make this script work on startup with erroring?
 
wojo
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 85
Joined: Tue Aug 21, 2018 4:37 am

Re: Action Timed Out only on startup, not subsequent runs of script

Mon Dec 24, 2018 5:29 am

Seems to be related to disk1, I formatted the disk as ext3 and it is fine now. Odd.
 
User avatar
sebastia
Forum Guru
Forum Guru
Posts: 1782
Joined: Tue Oct 12, 2010 3:23 am
Location: Antwerp, BE

Re: Action Timed Out only on startup, not subsequent runs of script

Mon Dec 24, 2018 6:51 am

Hey

I think that the IP stack may not be ready yet when this script is run, either internally or externally.
 
wojo
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 85
Joined: Tue Aug 21, 2018 4:37 am

Re: Action Timed Out only on startup, not subsequent runs of script

Mon Dec 24, 2018 6:58 am

I thought that as well, but with a :delay 15 or so that covers that just fine.

The issue was truly the disk1 issue, if I store the file on the internal storage or after formatting, it worked fine. How odd!
 
User avatar
sebastia
Forum Guru
Forum Guru
Posts: 1782
Joined: Tue Oct 12, 2010 3:23 am
Location: Antwerp, BE

Re: Action Timed Out only on startup, not subsequent runs of script

Mon Dec 24, 2018 7:18 am

Good to know, thx

Who is online

Users browsing this forum: No registered users and 33 guests