I’m trying to make an HTTP post on RouterOS 7.19.
The problem is, my MikroTik keeps crashing.
Since only RouterOS version 7 supports MQTT, we need to update the company’s MikroTik servers.
Previously, in RouterOS 6, we simply sent messages with:
/tool fetch mode=http url="http://10.11.11.22:1880/rute" http-method=post http-data="voltage=$voltage"
And it worked like a charm! But now it’s no longer supported. When I try, I get the error:
ether1 link down
and then
default {version: 2 router id:10.11.11.25} backbone {0.0.0.0} interface {broadcast 10.11.11.5%*1} destroyed
All the MikroTik ethers use OSPF in their configurations, and the device I’m trying to send the message to is connected to ether5 (normally, sometimes it can be on a switch in ether1, but on the MikroTik I’m using for testing, it’s on ether5).
Is there a way to send an HTTP POST without killing the MikroTik?
I would really appreciate your help as I have been trying for a week now
im using a RB960PGS
I’ve tried this script, trying to tell it not to use any route automatically, but nothing, it keeps telling me that OSPF was destroyed and I don’t understand why, is it perhaps a bug in this version?
# Configuración
:local targetHostName "raspberrypi"
:local routerName "xxxx"
# Abortamos si el equipo recién se encendió, por si se crea un loop
:if ([/system resource get uptime] < 60) do={
:log warning "Abortado: MikroTik recién encendido"
:return
}
# Obtener IP del Raspberry desde DHCP
:local leaseId [/ip dhcp-server lease find where host-name=$targetHostName]
:if ($leaseId = "") do={
:log warning "No se encontró lease para '$targetHostName'"
:return
}
:local targetIP [/ip dhcp-server lease get $leaseId address]
:if ($targetIP = "") do={
:log warning "No hay IP asignada al lease"
:return
}
# Verificar conectividad
:if ([/ping address=$targetIP count=2] = 0) do={
:log warning ("No responde " . $targetIP)
:return
}
# Agregar ruta directa temporal para evitar que se enrute por OSPF
:if ([:len [/ip route find where dst-address=($targetIP . "/32")]] = 0) do={
/ip route add dst-address=($targetIP . "/32") gateway=$targetIP comment="fetch-temp"
:log info ("Ruta directa temporal añadida para " . $targetIP)
}
# Obtener voltaje y temperatura del sistema
:local voltage [/system/health get [/system/health find where name="voltage"] value]
:local temp [/system/health get [/system/health find where name="temperature"] value]
# Enviar voltaje al Raspberry Pi
:do {
#/tool fetch url=("http://" . $targetIP . ":1880/voltage_in?voltage=" . $voltage) http-method=get keep-result=no
:log info ("Voltaje enviado a " . $targetIP . ": " . $voltage)
} on-error={
:log warning ("FALLÓ envío de voltaje a " . $targetIP)
}
# # Enviar temperatura al Raspberry Pi
# :do {
# /tool fetch url=("http://" . $targetIP . ":1880/temp_in?temperature=" . $temp) http-method=get keep-result=no
# :log info ("Temperatura enviada a " . $targetIP . ": " . $temp)
# } on-error={
# :log warning ("FALLÓ envío de temperatura a " . $targetIP)
# }
# Limpiar ruta temporal
:foreach r in=[/ip route find where dst-address=($targetIP . "/32") and comment="fetch-temp"] do={
/ip route remove $r
:log info ("Ruta temporal a " . $targetIP . " eliminada")
}