fetch error: maximal connection count reached

Hi to all.
I am use a simple script like this:

/tool fetch mode=http address=10.0.0.1 src-path=("/test/index.php") dst-path="/commands.txt" port=80 host=host.com;

......
some code
......
}

Sheduler run it each 30 seconds.

But after a while the script has stopped request URL.
When I run from a terminal it gives this error: failure: maximal connection count reached

Why connection count reached?
And how to avoid it?

I think there’s a limit (maybe around 4 - 6 or so) of fetch instances that can run simultaneously.

Are the scripts ending, or do you see a many of the same scripts in /system script job print? I’ve seen some cases where fetch can take a long time if no data is being returned by the server.

Yes you are right. Connection limit is 10.
For some reason I did not notice the hanging session in /system script job
They hang up if the http server returns nothing.
Thank you very much.

Glad it’s working for you :slight_smile:

Someone has found a solution ?

I have the same problem with up/down script in netwatch - it uses “tool fetch mode=http …” to update the web site showing status of over 200 monitored devices. When something wrong has happend and many of devices have been disconnected at the same time, netwatch scripts could not update status of all devices due “10 connection limit”.
In my opinion this limit should be an option or has to be increased/disabled.

Does anyone have a solution for this? I am having the same problem, it runs sometimes a few hundreds counts and sometimes it runs up to 20000 counts before /tool fetch fails to work.

Routerboard Firmware version: 3.18
Package version: 6.19

I’ve tried to upgrade both version to no avail.

Thanks.

I added ":delay x " at the beginning of up/down script ( where x is the last digit of IP address of “netwatched” device) and it helped a little.

To get around this, you need to look at the number of scripts in the job tab, and if it is too many delete them. This will free up the HTTP sessions and allow you to continue to use fetch.

:local b 0
:foreach ENTRY in=([/system script job find script="<SCRIPT NAME>"]) do={:set b ($b + 1)}
:if ($b > 3) do={/system script job remove [find script="<SCRIPT NAME>"]}

There is only one “/tool fetch” job in the scripts. I have tried to run the script manually when it failed by clicking on “Run Script” button but it did not help. The only way to recover it is to reboot or power cycle the unit.

I have a script MONITOR that runs every five minutes and occasionally gets stuck. Monitor should never run for more than a second.

So I have another script UNSTUCK scheduled to run very 3 minutes to delete the the MONITOR Script that is hung

This Unstuck script is:
/system script job remove [find where script=“MONITOR”];


works for me.

Previous poster Feklar had a more generic and better script.

I know it’s very old post but i had the same problem , rebooting the router solved it but many can’t just reboot so just disable any scheduler that has fetch and remove jobs and enviroment from script tap , It worled for me.

I was having the same problem. It was solved with a simple reboot of the router.