Why is sys.get_connectivity() always reporting NETWORK_CONNECTED on macOS? (SOLVED)


#1

I am working on a network reachability native extension, so I can get callback notification in lua when the network reachability changed (BTW, Defold API does NOT provide such functionality, is it?)
The native extension works pretty well on macOS. To verify if the native extension returns correct result, I called sys.get_connectivity() for double check. But I found when I disalbed the Wi-Fi connection (the only network connection) on my macbook, sys.get_connectivity() call still returns sys.NETWORK_CONNECTED.
Is it a bug or designed behavior?

I posted the log message below for your reference. (Reachability 0 means no conection, 1 means via cellular, 2 means other network connection). Thanks in advance.

INFO:DLIB: Log server started on port 50799
INFO:ENGINE: Engine service started on port 50800
INFO:ENGINE: Defold Engine 1.2.119 (2406775)
INFO:ENGINE: Loading data from: build/default
INFO:ENGINE: Initialised sound device ‘default’

INFO:DLIB: SSDP: Started on address 10.11.248.100
INFO:reachability: Reachability is changed to 2
DEBUG:SCRIPT: Reachability is changed to 2
DEBUG:SCRIPT: NETWORK_CONNECTED
INFO:reachability: Reachability is changed to 2
DEBUG:SCRIPT: Reachability is changed to 2
DEBUG:SCRIPT: NETWORK_CONNECTED
DEBUG:SCRIPT: main.script does not handle [proxy_unloaded]
INFO:DLIB: SSDP: Done on address 10.11.248.100
INFO:reachability: Reachability is changed to 2
DEBUG:SCRIPT: Reachability is changed to 2
DEBUG:SCRIPT: NETWORK_CONNECTED
INFO:reachability: Reachability is changed to 0
DEBUG:SCRIPT: Reachability is changed to 0
DEBUG:SCRIPT: NETWORK_CONNECTED
INFO:reachability: Reachability is changed to 0
DEBUG:SCRIPT: Reachability is changed to 0
DEBUG:SCRIPT: NETWORK_CONNECTED
INFO:reachability: Reachability is changed to 2
DEBUG:SCRIPT: Reachability is changed to 2
DEBUG:SCRIPT: NETWORK_CONNECTED
INFO:reachability: Reachability is changed to 2
DEBUG:SCRIPT: Reachability is changed to 2
DEBUG:SCRIPT: NETWORK_CONNECTED
INFO:reachability: Reachability is changed to 2
DEBUG:SCRIPT: Reachability is changed to 2
DEBUG:SCRIPT: NETWORK_CONNECTED
INFO:reachability: Reachability is changed to 2
DEBUG:SCRIPT: Reachability is changed to 2
DEBUG:SCRIPT: NETWORK_CONNECTED
INFO:DLIB: SSDP: Started on address 10.11.248.100
INFO:reachability: Reachability is changed to 2
DEBUG:SCRIPT: Reachability is changed to 2
DEBUG:SCRIPT: NETWORK_CONNECTED


#2

2018-01-11 22_48_38-Welcome - Zeal

It’s intended.

There are other ways you can check for connectivity. For DefQuest I just check for time servers to respond.


#3

Thanks @Pkeod for the clarification and tips, sorry I did not read the API reference carefully :grimacing: