I am trying to connect from my Android device to my server on the local network.
The connection is made in two ways:
HTTP, works fine all the time.
Sockets. This works fine at work, and at home.
Except when I connect to my corporate network through VPN at home.
We have eight dedicated Android devices (TC70s, if you must know) that connect to the local server through WiFi. We have been running this configuration for a few years now, works great. I haven't been concerned about this problem until yesterday, when one of the 8 devices at work had this connection issue. Now I am trying to figure out the problem before it gets worse.
When the Socket Connection fails, I get this exception:
"failed to connect to /192.168.1.xxx (port xxxx): connect failed: ECONNREFUSED (Connection refused)"
Thoughts? Why can't I connect?
Code:
// void for return value, does not throw an exception.
new SecurityManager().checkConnect(Configuration.socketServer, Configuration.socketPort);
Socket socket = new Socket("192.168.1.xxx", "xxxx");
I tried turning off Windows Defender, Whitelisting my server app in Windows Defender, checking that nothing else is listening to the port, turn off Windows Firewall.
The port is added to the ACL on my computer, as well as the one running the server at work.
The port is added to the firewall rules.
And yes, I have this in the manifest: uses-permission android:name="android.permission.INTERNET"
question from:
https://stackoverflow.com/questions/66055288/java-net-connectexception-failed-to-connect 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…