Search code examples
androidsmbwifijcifs

Android JCIFS/SMB does not work on network without internet


I'm working on an Android App that writes and reads files (*.txt) on a Windows PC. The App connects to a WiFi network and uses the SMB. The App works pretty well while the network has internet connection. When I disconnect Internet, the App can't connect to the PC. I mean, the device remains connected to the network on a WLAN, but there is no internet access on that network, and the App then can't connect to the folder on the Windows PC. I've searched on internet if this is a problem in the JCIFS library or Android system, and I found no information about it. So, maybe anyone has experienced this before? Is there any solution?

Here is some information about my project:
JCIFS - 1.3.18
Android Device 4.1.2 (16)
Android Manifest permissions - <uses-permission android:name="android.permission.INTERNET"

I've tried with ES File Explorer in the same scenario, connected to a WiFi network without Internet connection, then I searched for PCs in LAN and a message has been showed up: "Connect to a WLAN first".
Maybe is Android's fault?

Thanks in advance.


Solution

  • jcifs.Config.setProperty("jcifs.resolveOrder","BCAST,DNS");

    I use the above. The default order of LMHOSTS, WINS, BCAST, then DNS causes very long pauses waiting for a timeout when just on a LAN.