# What are the possibilities to repeat a sendTelegram if it fails

**URL:** <https://community.openhab.org/t/what-are-the-possibilities-to-repeat-a-sendtelegram-if-it-fails/107416>\
**Category:** Scripts & Rules\
**Tags:** rules\
**Created:** [October 30, 2020, 9:10pm UTC](https://community.openhab.org/t/what-are-the-possibilities-to-repeat-a-sendtelegram-if-it-fails/107416 "2020-10-30T21:10:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tombert](https://community.openhab.org/letter_avatar_proxy/v4/letter/t/258eb7/32.png) [@tombert](https://community.openhab.org/u/tombert)\
**Post date:** [October 30, 2020, 9:10pm UTC](https://community.openhab.org/t/what-are-the-possibilities-to-repeat-a-sendtelegram-if-it-fails/107416/1 "2020-10-30T21:10:35Z")

</div>

Hi,

imagine I put a `sendTelegram` into my rules file and it fails because there is no internet connection. What are my possibilities to retry `sendTelegram` for e.g. 10 minutes every minute and only then give up?  
(I have lots of `sendTelegram` statements with various messages in separate rules)

As I understood, rules run single threaded? So if I would block inside a rule the whole rules engine will stuck. Is there a neat way using the “standard” rules engine?

I was also thinking maybe to spawn a separate linux process which sends the messages, so there would be for each new `sendTelegram` a new process until it succeeds or gives up trying.

thx!

---

<div class="post-metadata">

**Author:** ![denominator](https://community.openhab.org/user_avatar/community.openhab.org/denominator/32/37349_2.png) [@denominator](https://community.openhab.org/u/denominator)\
**Post date:** [October 30, 2020, 9:21pm UTC](https://community.openhab.org/t/what-are-the-possibilities-to-repeat-a-sendtelegram-if-it-fails/107416/2 "2020-10-30T21:21:05Z")

</div>

Have you tested what happens if there is no internet connection? What happens.

In you rules you could check if you have an internet dropout and then write the message to a text file. Then when internet is reconnected send those messages line by line to telegram.

---

<div class="post-metadata">

**Author:** ![rossko57](https://community.openhab.org/user_avatar/community.openhab.org/rossko57/32/70263_2.png) [@rossko57](https://community.openhab.org/u/rossko57)\
**Post date:** [October 30, 2020, 10:08pm UTC](https://community.openhab.org/t/what-are-the-possibilities-to-repeat-a-sendtelegram-if-it-fails/107416/3 "2020-10-30T22:08:52Z")

</div>

> [@tombert](#):
>
> So if I would block inside a rule …

Why would you do that? The rules systems allow you to create timers and schedule a task for a time in the future, like trying again.

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [October 31, 2020, 2:19am UTC](https://community.openhab.org/t/what-are-the-possibilities-to-repeat-a-sendtelegram-if-it-fails/107416/4 "2020-10-31T02:19:48Z")

</div>

> [@Design Pattern: Looping Timers](https://community.openhab.org/t/design-pattern-looping-timers/47699):
>
> Edit: Update for OH 4 Please see [Design Pattern: What is a Design Pattern and How Do I Use Them](https://community.openhab.org/t/design-pattern-what-is-a-design-pattern-and-how-do-i-use-them/40319) to understand the scope and purpose of this and other Design Patterns. Problem Statement Often one may require a loop in a Rule, to wait for some event to occur or some state to change before doing something. For example, if a door is opened for a long time to send an alert every hour until the door is closed. Concept Use a Timer that reschedules itself instead of a while loop or sleeps. …

---

<div class="post-metadata">

**Author:** ![tombert](https://community.openhab.org/letter_avatar_proxy/v4/letter/t/258eb7/32.png) [@tombert](https://community.openhab.org/u/tombert)\
**Post date:** [October 31, 2020, 9:02pm UTC](https://community.openhab.org/t/what-are-the-possibilities-to-repeat-a-sendtelegram-if-it-fails/107416/5 "2020-10-31T21:02:45Z")

</div>

I’ll try the looping timers pattern. Thank you very much for pointing me to it!
