I have some Java code that connects to a Windows application a virtual machine (VirtualBox) over a bridged WLAN adapter. The strange thing here, is that this works "sometimes", and when it starts working, it works for some time, and then stops again.
The code has been working fine for years, it is just this combination of mobile terminal (it's Android) and virtualised server that is b0rking on me:
URL url = new URL(urlString);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
connection.setDoOutput(true);
// 'tel' is the String I am sending
connection.setFixedLengthStreamingMode(tel.getBytes().length);
connection.setConnectTimeout(10000);
connection.setReadTimeout(requestTel.getTimeout());
// this call throws the exception
OutputStream o = connection.getOutputStream();
The exception I am getting from the Java code is this ConnectException
:
java.net.ConnectException: Failed to connect to /192.168.3.145:8080
According to the documentation, this can be when no process is listening (there is), but apparently this can also mean routing is incorrect or something else. I would like to know the underlying TCP error, so I can troubleshoot this better.
(When connecting to the service from the virtual host, it connects fine. When connecting from the mobile terminal to the host (emulating the service), it connects fine. After re-trying several times, it works for a limited time (it's almost like there is a firewall that needs kicking through and is rebuilt after a minute or so).)
Update when connecting my virtual guest to a wired port, it seems to work fine...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…