Browser -> isOnline always returns true

Bugs will be moved here once resolved.

Post » Tue Feb 10, 2015 10:24 am

Problem Description
When previewing in Chrome, Firefox and mobile compiled with Intel XDK the behaviour Browser -> is online always returns true. On IE it works fine.


Description of Capx
A very simple test of the behaviour in question. Here's the content:

Image

Steps to Reproduce Bug
  • Step 1 Run the capx.
  • Step 2 Disconnect the internet.

Observed Result
The text label still says "connected". Apparently the condition returns true even without the connection.

Expected Result
The condition should return false, so that the else condition would fire and the label should change to "disconnected."

Affected Browsers
  • Chrome: (YES)
  • FireFox: (YES)
  • Internet Explorer: (NO)

Operating System and Service Pack
Windows 8.1

Construct 2 Version ID
r196.2
You do not have the required permissions to view the files attached to this post.
B
16
S
7
G
1
Posts: 151
Reputation: 3,101

Post » Tue Feb 10, 2015 3:58 pm

This is not a C2 bug. It is simply returning the navigator.onLine property, which as the MDN describes has a complicated definition: https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine.onLine

The spec says:
The navigator.onLine attribute must return false if the user agent will not contact the network when the user follows links or when a script requests a remote page (or knows that such an attempt would fail)...


Browsers interpret this differently. Some browsers only return false if they are explicitly put in to "offline mode", others only if they are not connected to any LAN, and perhaps others if they cannot reach some fixed server on the Internet (say google.com). It's surprisingly difficult to define "online". For example if you can access company intranet websites, but not outside internet websites, are you online (in the sense that you can access remote pages) or offline (in the sense that you can't access other servers elsewhere)?
Scirra Founder
B
384
S
227
G
86
Posts: 24,139
Reputation: 190,761

Post » Wed Feb 11, 2015 7:55 am

I see. Indeed I ran into some difficulties in the past because my apps 'thought' they were online when connected to intranet. I guess I'll write a plugin that pings Google or something like that. Thank you for the info Ashley.
B
16
S
7
G
1
Posts: 151
Reputation: 3,101


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest