# Connection check

**URL:** https://community.thunkable.com/t/connection-check/52482
**Category:** Questions about Thunkable X
**Created:** [October 18, 2018, 10:02am UTC](https://community.thunkable.com/t/connection-check/52482 "2018-10-18T10:02:25Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Antonio\_Vitolo](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@Antonio\_Vitolo](https://community.thunkable.com/u/Antonio_Vitolo)
#### Post date: [October 18, 2018, 10:02am UTC](https://community.thunkable.com/t/connection-check/52482/1 "2018-10-18T10:02:25Z")

</div>

Hi,  
How can I check if the device is connected to the internet?

Thanks.

---

<div class="post-metadata">

### Author: ![fabioirmao](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/fabioirmao/32/43097_2.png) [@fabioirmao](https://community.thunkable.com/u/fabioirmao)
#### Post date: [October 18, 2018, 12:37pm UTC](https://community.thunkable.com/t/connection-check/52482/2 "2018-10-18T12:37:14Z")

</div>

Next time, try to search first:

[http://community.thunkable.com/t/internet-connection-check-solved/2091](http://community.thunkable.com/t/internet-connection-check-solved/2091)

---

<div class="post-metadata">

### Author: ![Antonio\_Vitolo](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@Antonio\_Vitolo](https://community.thunkable.com/u/Antonio_Vitolo)
#### Post date: [October 18, 2018, 12:46pm UTC](https://community.thunkable.com/t/connection-check/52482/3 "2018-10-18T12:46:14Z")

</div>

with classic thunkable I can do it … but my question was how to do with thuncable x … ???

---

<div class="post-metadata">

### Author: ![fabioirmao](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/fabioirmao/32/43097_2.png) [@fabioirmao](https://community.thunkable.com/u/fabioirmao)
#### Post date: [October 18, 2018, 12:47pm UTC](https://community.thunkable.com/t/connection-check/52482/4 "2018-10-18T12:47:14Z")

</div>

The idea is the same…take a look on the link above

---

<div class="post-metadata">

### Author: ![Antonio\_Vitolo](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@Antonio\_Vitolo](https://community.thunkable.com/u/Antonio_Vitolo)
#### Post date: [October 18, 2018, 1:48pm UTC](https://community.thunkable.com/t/connection-check/52482/5 "2018-10-18T13:48:47Z")

</div>

in fact, I did it but it does not work …

 ![Immagine1](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/a/caba2b3870ca85a077bc57cb5c131edc070ef39d.jpeg)

---

<div class="post-metadata">

### Author: ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)
#### Post date: [October 18, 2018, 3:39pm UTC](https://community.thunkable.com/t/connection-check/52482/6 "2018-10-18T15:39:04Z")

</div>

Hi,

Hi, try searching for a simple and high-speed online echo service. google.it is far from the best option.

One option is to request [http://ip-api.com/json](http://ip-api.com/json) and check the answer.

---

<div class="post-metadata">

### Author: ![Antonio\_Vitolo](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@Antonio\_Vitolo](https://community.thunkable.com/u/Antonio_Vitolo)
#### Post date: [October 18, 2018, 7:35pm UTC](https://community.thunkable.com/t/connection-check/52482/7 "2018-10-18T19:35:08Z")

</div>

I tried with URL:

[http://ip-api.com/json](http://ip-api.com/json)

but it gives me error:

Network request failed

while nothing Response and Status … ???

but the internet is there …

you could give me an example, thank you.

---

<div class="post-metadata">

### Author: ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)
#### Post date: [October 19, 2018, 7:19am UTC](https://community.thunkable.com/t/connection-check/52482/8 "2018-10-19T07:19:32Z")

</div>

The timer in the loop set for 2 seconds.

The problem is that with frequent polling of servers your IP can be blocked, so instead of [https://ipecho.net/](https://ipecho.net/) it’s better to use the current time service (for example [https://timezonedb.com/](https://timezonedb.com/)), which can be accessed once a second and lock will not be.

![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/8/e84db0a85fa4ac2d9c725fd011fb43b4d67d2938.png)

---

<div class="post-metadata">

### Author: ![Antonio\_Vitolo](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@Antonio\_Vitolo](https://community.thunkable.com/u/Antonio_Vitolo)
#### Post date: [October 19, 2018, 8:02am UTC](https://community.thunkable.com/t/connection-check/52482/9 "2018-10-19T08:02:22Z")

</div>

I tried it works …  
but if I disable the internet with the active app, it always tells me internet ok … ???

 ![Immagine1](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/0/4006a6ff1a7e855afb913c61fd7f6637438f1753.jpeg)

---

<div class="post-metadata">

### Author: ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)
#### Post date: [October 19, 2018, 8:49am UTC](https://community.thunkable.com/t/connection-check/52482/10 "2018-10-19T08:49:33Z")

</div>

With [https://timezonedb.com](https://timezonedb.com) needs to work through the API to get time, and not just call this site.

First try my example [https://ipecho.net/](https://ipecho.net/). It has no buttons.

---

<div class="post-metadata">

### Author: ![Antonio\_Vitolo](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@Antonio\_Vitolo](https://community.thunkable.com/u/Antonio_Vitolo)
#### Post date: [October 19, 2018, 9:05am UTC](https://community.thunkable.com/t/connection-check/52482/11 "2018-10-19T09:05:21Z")

</div>

ok …  
I tried your solution and I confirm that it works only at the start of the app, if you connect or disconnect the internet, with the app running, always recognizes the status that recognized at startup …

 ![Immagine1](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/1/019a33edac7e399ac1d7bca4a14f341a28c4b226.jpeg)

---

<div class="post-metadata">

### Author: ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)
#### Post date: [October 19, 2018, 9:29am UTC](https://community.thunkable.com/t/connection-check/52482/12 "2018-10-19T09:29:38Z")

</div>

Have you enabled for Timer.Loops = true? This application works well for me both at the beginning of the launch and after that.

---

<div class="post-metadata">

### Author: ![Antonio\_Vitolo](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@Antonio\_Vitolo](https://community.thunkable.com/u/Antonio_Vitolo)
#### Post date: [October 19, 2018, 10:00am UTC](https://community.thunkable.com/t/connection-check/52482/13 "2018-10-19T10:00:34Z")

</div>

ok, I activated loop timer …  
we are almost there…

if I start the app with internet to off, show disconnect and if I put the internet on, show connect … then ok …

but if I put internet to off, always show connect … why?

---

<div class="post-metadata">

### Author: ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)
#### Post date: [October 19, 2018, 10:09am UTC](https://community.thunkable.com/t/connection-check/52482/14 "2018-10-19T10:09:38Z")

</div>

I’ll redo the algorithm

---

<div class="post-metadata">

### Author: ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)
#### Post date: [October 19, 2018, 10:27am UTC](https://community.thunkable.com/t/connection-check/52482/15 "2018-10-19T10:27:32Z")

</div>

Check it.

![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/f/6f5303f275a480cd918a452a0c6e0d4fc5ff2662.png)

[https://x.thunkable.com/projects/5bc44f9e445e8711fe3ca1d7/project/properties/designer/](https://x.thunkable.com/projects/5bc44f9e445e8711fe3ca1d7/project/properties/designer/)

---

<div class="post-metadata">

### Author: ![Antonio\_Vitolo](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@Antonio\_Vitolo](https://community.thunkable.com/u/Antonio_Vitolo)
#### Post date: [October 19, 2018, 11:00am UTC](https://community.thunkable.com/t/connection-check/52482/16 "2018-10-19T11:00:52Z")

</div>

does the same thing …

---

<div class="post-metadata">

### Author: ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)
#### Post date: [October 19, 2018, 11:43am UTC](https://community.thunkable.com/t/connection-check/52482/17 "2018-10-19T11:43:58Z")

</div>

What version of iOS are you using? I work well on iOS 10.3 and 11.4. On Android, this example also works.

---

<div class="post-metadata">

### Author: ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)
#### Post date: [October 19, 2018, 11:51am UTC](https://community.thunkable.com/t/connection-check/52482/18 "2018-10-19T11:51:26Z")

</div>

There is a more reliable way to determine the presence of a network. With [https://timezonedb.com](https://timezonedb.com) you need to take every second time and compare the current time value with the previous one. If the current time is greater than the previous one, then there is a connection, otherwise there is no connection. I will try to implement this method, but you need to register on this service to get the API key.

---

<div class="post-metadata">

### Author: ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)
#### Post date: [October 19, 2018, 12:08pm UTC](https://community.thunkable.com/t/connection-check/52482/19 "2018-10-19T12:08:18Z")

</div>

No, using time I don’t like the option. You need to see why my example is not working. Everything is simple in it. We regularly send a request. If the answer came - there is a connection, if there is no answer, then there is no connection.

---

<div class="post-metadata">

### Author: ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)
#### Post date: [October 19, 2018, 12:15pm UTC](https://community.thunkable.com/t/connection-check/52482/20 "2018-10-19T12:15:21Z")

</div>

Another option. If it is impossible to get an answer, an error occurs. This example should work 100%.

![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/d/2d2d9dad8136231fb4457e1263a4df544fb01b73.png)

[Next page](https://community.thunkable.com/t/connection-check/52482.md?page=2)
