# How to check if there is an active internet connection with Ruby API?

**URL:** <https://forums.sketchup.com/t/how-to-check-if-there-is-an-active-internet-connection-with-ruby-api/60820>\
**Category:** Ruby API\
**Tags:** sketchup, extension\
**Created:** [January 30, 2018, 1:28pm UTC](https://forums.sketchup.com/t/how-to-check-if-there-is-an-active-internet-connection-with-ruby-api/60820 "2018-01-30T13:28:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![timucin.kabak](https://avatars.discourse-cdn.com/v4/letter/t/b2d939/32.png) [@timucin.kabak](https://forums.sketchup.com/u/timucin.kabak)\
**Post date:** [January 30, 2018, 1:28pm UTC](https://forums.sketchup.com/t/how-to-check-if-there-is-an-active-internet-connection-with-ruby-api/60820/1 "2018-01-30T13:28:41Z")

</div>

I need to check if there is an active internet connection before opening a URL in HTMLDialog to show a warning message that user needs it.

But I couldn’t find a way to check it. Can anyone help me?

---

<div class="post-metadata">

**Author:** ![tt\_su](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tt_su/32/17_2.png) [@tt\_su](https://forums.sketchup.com/u/tt_su)\
**Post date:** [January 30, 2018, 1:41pm UTC](https://forums.sketchup.com/t/how-to-check-if-there-is-an-active-internet-connection-with-ruby-api/60820/2 "2018-01-30T13:41:10Z")

</div>

```ruby
Sketchup.is_online

```

> **[Module: Sketchup](https://ruby.sketchup.com/Sketchup.html#is_online-class_method)**
>
> The Sketchup module contains a number of important utility methods for use in your Ruby scripts.

Note that I’m not sure if this method cache the results or not. (As in, if the network status changes during a session, I’m not sure if this method will reflect this.)

The method basically just ping a website - which you could do yourself with Ruby’s built int `Net::Http` or SketchUp’s `Sketchup::Http` modules: [Module: Sketchup::Http — SketchUp Ruby API Documentation](http://ruby.sketchup.com/Sketchup/Http.html) (In case you need full control over the internet check)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sketchup/original/3X/f/2/f2a121500b085ed60806607a82720b092d800bb3.png) [@system](https://forums.sketchup.com/u/system)\
**Post date:** [May 2, 2018, 5:41am UTC](https://forums.sketchup.com/t/how-to-check-if-there-is-an-active-internet-connection-with-ruby-api/60820/3 "2018-05-02T05:41:15Z")

</div>

Closed on May 2, 2018, 5:41am UTC

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.
