3.3.3 Keine Internetverbindung
Re: 3.3.3 Keine Internetverbindung
also bei mir auf arbeit hat die 3.4 noch das gleiche problem. datenaktualisierung funktioniert immer erst beim n'ten versuch, weil der verbindungstest scheitert. omdb-verbindung übers wirschauen-plugin funktioniert zeitgleich problemlos.
Re: 3.3.3 Keine Internetverbindung
Da kann ich dann aber auch nichts mehr dran ändern oder welche Response-Codes sollte der Test denn noch akzeptieren?
http://sourceforge.net/p/tvbrowser/code ... ction.java
http://sourceforge.net/p/tvbrowser/code ... ction.java
"First they ignore you, then they ridicule you, then they fight you, then you win." - Mahatma Gandhi
Unterstütze die Weiterentwicklung von TV-Browser
Unterstütze die Weiterentwicklung von TV-Browser
Re: 3.3.3 Keine Internetverbindung
Ich habe das ziemlich rudimentär gelöst. Keine WAN-IP = kein Internetzugriff
Dazu frage ich einfach http://checkip.dyndns.org/ ab. Den PHP-3-Zeiler dafür könnte man auch auf jedem beliebigen Web-Server laufen lassen, es erfolgt ja sowieso eine Abfrage für Updates etc. pp.
Dazu frage ich einfach http://checkip.dyndns.org/ ab. Den PHP-3-Zeiler dafür könnte man auch auf jedem beliebigen Web-Server laufen lassen, es erfolgt ja sowieso eine Abfrage für Updates etc. pp.
Gestern standen wir vor dem Abgrund; heute sind wir bereits einen Schritt weiter...
Re: 3.3.3 Keine Internetverbindung
hm... also zunächst mal das übliche problem des unzureichenden loggings. dass in zeile 126 die exception kommentarlos geschluckt wird, ist nicht unbedingt hilfreich. abgesehen davon wäre ein elaboriertes logging (aka log4j oder ähnliches) natürlich anzuraten. wie dem auch sei, ich habe mir die klasse einfach mal gegriffen, das störende gui-zeug rausgeworfen und hier und da eine kleinigkeit geändert. herausgekommen ist dabei das:
der output dazu ist:
geht wohl wegen des threadings ein wenig durcheinander.
fazit:
- der aufruf von duckduckgo.com läuft grundsätzlich in eine unknownHostException (die url ist im browser mit dem gleichen proxy allerdings problemlos aufrufbar). ich tippe mal auf ein https-problem. bedeutet, dass die url nutzlos ist, sollte aber den check nicht grundsätzlich kompromittieren.
- alle anderen urls sind aber ebenfalls nicht reachable - nur sporadisch kommt da mal ein true zurück.
- 301 ist moved permanently, der sollte wohl akzeptiert werden. kommt aber auch oft einfach 200 zurück. wie mir scheint öfter, als der verbindungstest dann letztlich 'ok' sagt. ich werd mal das threading noch ausbauen, damit die reihenfolge nicht so durcheinander ist.
Code: Alles auswählen
package urlcheck;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import javax.net.ssl.HttpsURLConnection;
/**
* Checks the Network and creates a Waiting-Dialog if necessary
*
* @since 2.2
*/
class CheckNetworkConnection {
private boolean mCheckRunning = true;
private boolean mResult = false;
private final static String[] CHECK_URLS = { "https://duckduckgo.com/", "http://www.google.com/", "http://www.yahoo.com/", "http://www.bing.com/" };
/**
* Check the Network
*
* @return true, if the connection is working
*/
public boolean checkConnection() {
try {
for (String url : CHECK_URLS) {
boolean urlOk = checkConnection(new URL(url));
System.out.println("url: " + url + " reachable -> " + urlOk);
if (urlOk) {
return true;
}
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
return false;
}
/**
* Checks if a internet connection to a specific Server can be established
*
* @param url
* check this Server
* @return true, if a connection can be established
*/
public boolean checkConnection(final URL url) {
// Start Check in second Thread
new Thread(new Runnable() {
public void run() {
mCheckRunning = true;
mResult = false;
try {
URLConnection test = url.openConnection();
if (test instanceof HttpsURLConnection) {
HttpsURLConnection connection = (HttpsURLConnection) test;
mResult = (connection.getResponseCode() == HttpsURLConnection.HTTP_OK)
|| (connection.getResponseCode() == HttpsURLConnection.HTTP_SEE_OTHER)
|| (connection.getResponseCode() == HttpsURLConnection.HTTP_ACCEPTED)
|| (connection.getResponseCode() == HttpsURLConnection.HTTP_CREATED);
} else {
HttpURLConnection connection = (HttpURLConnection) test;
mResult = (connection.getResponseCode() == HttpURLConnection.HTTP_OK)
|| (connection.getResponseCode() == HttpURLConnection.HTTP_SEE_OTHER)
|| (connection.getResponseCode() == HttpURLConnection.HTTP_ACCEPTED)
|| (connection.getResponseCode() == HttpURLConnection.HTTP_CREATED);
System.out.println(connection.getURL() + " response code: " + connection.getResponseCode());
}
} catch (IOException e) {
e.printStackTrace();
}
mCheckRunning = false;
};
}, "Check network connection").start();
int num = 0;
// Wait till second Thread is finished or
// Settings.propNetworkCheckTimeout is reached
//int timeout = Settings.propNetworkCheckTimeout.getInt() / 100;
int timeout = 100; //10s
while ((mCheckRunning) && (num < timeout)) {
num++;
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
return mResult;
}
public static void main(String[] args) {
System.setProperty("http.proxyHost", xxx);
System.setProperty("http.proxyPort", xxx);
for (int i = 0; i < 10; i++) {
System.out.println(new CheckNetworkConnection().checkConnection());
}
}
}
Code: Alles auswählen
java.net.UnknownHostException: duckduckgo.com
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
at urlcheck.CheckNetworkConnection$1.run(CheckNetworkConnection.java:58)
at java.lang.Thread.run(Unknown Source)
url: https://duckduckgo.com/ reachable -> false
url: http://www.google.com/ reachable -> false
url: http://www.yahoo.com/ reachable -> false
http://www.bing.com/ response code: 200
url: http://www.bing.com/ reachable -> true
true
java.net.UnknownHostException: duckduckgo.com
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
at urlcheck.CheckNetworkConnection$1.run(CheckNetworkConnection.java:58)
at java.lang.Thread.run(Unknown Source)
http://www.google.de/?gfe_rd=cr&ei=cXOyU-WWHorSsga3xYH4DA response code: 200
http://www.yahoo.com/ response code: 301
url: https://duckduckgo.com/ reachable -> false
url: http://www.google.com/ reachable -> false
http://www.yahoo.com/ response code: 301
url: http://www.yahoo.com/ reachable -> false
url: http://www.bing.com/ reachable -> false
false
java.net.UnknownHostException: duckduckgo.com
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
at urlcheck.CheckNetworkConnection$1.run(CheckNetworkConnection.java:58)
at java.lang.Thread.run(Unknown Source)
http://www.google.de/?gfe_rd=cr&ei=cXOyU6n9Lo7esgayuoGAAQ response code: 200
url: https://duckduckgo.com/ reachable -> false
url: http://www.google.com/ reachable -> false
http://www.yahoo.com/ response code: 301
url: http://www.yahoo.com/ reachable -> false
url: http://www.bing.com/ reachable -> false
false
java.net.UnknownHostException: duckduckgo.com
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
at urlcheck.CheckNetworkConnection$1.run(CheckNetworkConnection.java:58)
at java.lang.Thread.run(Unknown Source)
http://www.google.de/?gfe_rd=cr&ei=cnOyU8fCA4rSsga3xYH4DA response code: 200
http://www.bing.com/ response code: 200
url: https://duckduckgo.com/ reachable -> false
url: http://www.google.com/ reachable -> false
http://www.bing.com/ response code: 200
http://www.yahoo.com/ response code: 301
url: http://www.yahoo.com/ reachable -> false
url: http://www.bing.com/ reachable -> false
false
java.net.UnknownHostException: duckduckgo.com
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
at urlcheck.CheckNetworkConnection$1.run(CheckNetworkConnection.java:58)
at java.lang.Thread.run(Unknown Source)
http://www.google.de/?gfe_rd=cr&ei=cnOyU8bzFsmKswa91IDwDw response code: 200
url: https://duckduckgo.com/ reachable -> false
url: http://www.google.com/ reachable -> false
url: http://www.yahoo.com/ reachable -> false
url: http://www.bing.com/ reachable -> false
false
java.net.UnknownHostException: duckduckgo.com
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
at urlcheck.CheckNetworkConnection$1.run(CheckNetworkConnection.java:58)
at java.lang.Thread.run(Unknown Source)
url: https://duckduckgo.com/ reachable -> false
url: http://www.google.com/ reachable -> false
url: http://www.yahoo.com/ reachable -> false
url: http://www.bing.com/ reachable -> false
false
http://www.yahoo.com/ response code: 301
java.net.UnknownHostException: duckduckgo.com
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
at urlcheck.CheckNetworkConnection$1.run(CheckNetworkConnection.java:58)
at java.lang.Thread.run(Unknown Source)
http://www.bing.com/ response code: 200
http://www.bing.com/ response code: 200
http://www.google.de/?gfe_rd=cr&ei=cnOyU9amKcjDtAbS4IGoAw response code: 200
url: https://duckduckgo.com/ reachable -> false
url: http://www.google.com/ reachable -> false
url: http://www.yahoo.com/ reachable -> false
http://www.yahoo.com/ response code: 301
http://www.bing.com/ response code: 200
http://www.yahoo.com/ response code: 301
http://www.google.de/?gfe_rd=cr&ei=cnOyU_bGMMqKswaxroDQDA response code: 200
http://www.bing.com/ response code: 200
url: http://www.bing.com/ reachable -> true
true
java.net.UnknownHostException: duckduckgo.com
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
at urlcheck.CheckNetworkConnection$1.run(CheckNetworkConnection.java:58)
at java.lang.Thread.run(Unknown Source)
http://www.google.de/?gfe_rd=cr&ei=cnOyU5r_NonMtAbv0YGoCQ response code: 200
url: https://duckduckgo.com/ reachable -> false
url: http://www.google.com/ reachable -> false
url: http://www.yahoo.com/ reachable -> false
url: http://www.bing.com/ reachable -> false
false
java.net.UnknownHostException: duckduckgo.com
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
at urlcheck.CheckNetworkConnection$1.run(CheckNetworkConnection.java:58)
at java.lang.Thread.run(Unknown Source)
url: https://duckduckgo.com/ reachable -> false
url: http://www.google.com/ reachable -> false
url: http://www.yahoo.com/ reachable -> false
url: http://www.bing.com/ reachable -> false
false
java.net.UnknownHostException: duckduckgo.com
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
http://www.yahoo.com/ response code: 301
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
at urlcheck.CheckNetworkConnection$1.run(CheckNetworkConnection.java:58)
at java.lang.Thread.run(Unknown Source)
http://www.bing.com/ response code: 200
url: https://duckduckgo.com/ reachable -> false
url: http://www.google.com/ reachable -> false
http://www.google.de/?gfe_rd=cr&ei=c3OyU4CvDITjsgbRg4DYDQ response code: 200
http://www.yahoo.com/ response code: 301
http://www.yahoo.com/ response code: 301
http://www.google.de/?gfe_rd=cr&ei=c3OyU6j8EsXfsgbiyYHoAg response code: 200
url: http://www.yahoo.com/ reachable -> false
url: http://www.bing.com/ reachable -> false
false
http://www.bing.com/ response code: 200
http://www.google.de/?gfe_rd=cr&ei=c3OyU6LhGISLtQbq_IHQCg response code: 200
http://www.bing.com/ response code: 200
fazit:
- der aufruf von duckduckgo.com läuft grundsätzlich in eine unknownHostException (die url ist im browser mit dem gleichen proxy allerdings problemlos aufrufbar). ich tippe mal auf ein https-problem. bedeutet, dass die url nutzlos ist, sollte aber den check nicht grundsätzlich kompromittieren.
- alle anderen urls sind aber ebenfalls nicht reachable - nur sporadisch kommt da mal ein true zurück.
- 301 ist moved permanently, der sollte wohl akzeptiert werden. kommt aber auch oft einfach 200 zurück. wie mir scheint öfter, als der verbindungstest dann letztlich 'ok' sagt. ich werd mal das threading noch ausbauen, damit die reihenfolge nicht so durcheinander ist.
Re: 3.3.3 Keine Internetverbindung
ok, wir haben hier definitiv irgendein theading-problem. neues testprogramm, alles single-threaded und duckduckgo mal aus der liste genommen, damit der output übersichtlicher wird:
output:
Code: Alles auswählen
package urlcheck;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import javax.net.ssl.HttpsURLConnection;
/**
* Checks the Network and creates a Waiting-Dialog if necessary
*
* @since 2.2
*/
class CheckNetworkConnection {
private boolean mResult = false;
private final static String[] CHECK_URLS = { "http://www.google.com/", "http://www.yahoo.com/", "http://www.bing.com/" };
/**
* Check the Network
*
* @return true, if the connection is working
*/
public boolean checkConnection() {
try {
for (String url : CHECK_URLS) {
boolean urlOk = checkConnection(new URL(url));
System.out.println("url: " + url + " reachable -> " + urlOk);
if (urlOk) {
return true;
}
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
return false;
}
/**
* Checks if a internet connection to a specific Server can be established
*
* @param url
* check this Server
* @return true, if a connection can be established
*/
public boolean checkConnection(final URL url) {
mResult = false;
try {
URLConnection test = url.openConnection();
if (test instanceof HttpsURLConnection) {
HttpsURLConnection connection = (HttpsURLConnection) test;
mResult = (connection.getResponseCode() == HttpsURLConnection.HTTP_OK)
|| (connection.getResponseCode() == HttpsURLConnection.HTTP_SEE_OTHER)
|| (connection.getResponseCode() == HttpsURLConnection.HTTP_ACCEPTED)
|| (connection.getResponseCode() == HttpsURLConnection.HTTP_CREATED);
} else {
HttpURLConnection connection = (HttpURLConnection) test;
mResult = (connection.getResponseCode() == HttpURLConnection.HTTP_OK)
|| (connection.getResponseCode() == HttpURLConnection.HTTP_SEE_OTHER)
|| (connection.getResponseCode() == HttpURLConnection.HTTP_ACCEPTED)
|| (connection.getResponseCode() == HttpURLConnection.HTTP_CREATED);
System.out.println(connection.getURL() + " response code: " + connection.getResponseCode());
}
} catch (IOException e) {
e.printStackTrace();
}
return mResult;
}
public static void main(String[] args) {
System.setProperty("http.proxyHost", xxx);
System.setProperty("http.proxyPort", xxx);
for (int i = 0; i < 10; i++) {
System.out.println(new CheckNetworkConnection().checkConnection());
}
}
}
Code: Alles auswählen
http://www.google.de/?gfe_rd=cr&ei=fnayU_WxLdGLswaI7oCQAw response code: 200
url: http://www.google.com/ reachable -> true
true
http://www.google.de/?gfe_rd=cr&ei=fnayU761O8-Lswa4l4HoDw response code: 200
url: http://www.google.com/ reachable -> true
true
http://www.google.de/?gfe_rd=cr&ei=f3ayU6a2C87esgaP94CwAw response code: 200
url: http://www.google.com/ reachable -> true
true
http://www.google.de/?gfe_rd=cr&ei=f3ayU6vLF87esgaP94CwAw response code: 200
url: http://www.google.com/ reachable -> true
true
http://www.google.de/?gfe_rd=cr&ei=f3ayU_z4JJHasgbIsoCYDg response code: 200
url: http://www.google.com/ reachable -> true
true
http://www.google.de/?gfe_rd=cr&ei=f3ayU9TxMM7esgaP94CwAw response code: 200
url: http://www.google.com/ reachable -> true
true
http://www.google.de/?gfe_rd=cr&ei=gHayU_xIzuKyBurZgVA response code: 200
url: http://www.google.com/ reachable -> true
true
http://www.google.de/?gfe_rd=cr&ei=gHayU7bYDNGLswaI7oCQAw response code: 200
url: http://www.google.com/ reachable -> true
true
http://www.google.de/?gfe_rd=cr&ei=gHayU9_qGYaEtQaPyoCYAg response code: 200
url: http://www.google.com/ reachable -> true
true
http://www.google.de/?gfe_rd=cr&ei=gHayU92YJs7isgbq2YFQ response code: 200
url: http://www.google.com/ reachable -> true
true
Re: 3.3.3 Keine Internetverbindung
Bei mir wird https://duckduckgo.com/ aber sofort akzeptiert, da dürfte https bei dir wohl gesperrt sein.
EDIT: Ein Threading-Problem habe ich aber auch schon vermutet, denn mResult wird zu Beginn ja immer zurückgesetzt auf false.
EDIT: Ein Threading-Problem habe ich aber auch schon vermutet, denn mResult wird zu Beginn ja immer zurückgesetzt auf false.
"First they ignore you, then they ridicule you, then they fight you, then you win." - Mahatma Gandhi
Unterstütze die Weiterentwicklung von TV-Browser
Unterstütze die Weiterentwicklung von TV-Browser
Re: 3.3.3 Keine Internetverbindung
ääähm... jaa... das ist ja auch kein wunder, dass da alles durcheinander geht. checkConnection ruft checkConnection(final URL url) auf, wo der thread gestartet wird. sprich: alle 4 urls werden parallel geprüft. das ergebnis wird dann in eine einzige instanz-var geschrieben (private boolean mResult). mal ab davon, dass der zuriff darauf nicht threadsafe ist, wird das ganze ergebnis natürlich false, wenn der letzte schreibende zugriff false sagt. ich vermute, das wird in 99% der fälle die gescheiterte ssl-verbindung zu duckduckgo sein.
Re: 3.3.3 Keine Internetverbindung
hm... abgesehen davon ist natürlich die frage zu stellen, ob man überhaupt den response code auswerten muss. das soll ja ein connection-check sein und kein server-check. ist ist völlig unerheblich, mit welchem response code der server antwortet, solange überhaupt eine antwort kommt.
Re: 3.3.3 Keine Internetverbindung
Nein, so läuft das nicht ab. Die Methode checkConnection hat eine Warteschleife am Ende. Wenn du einfach den Dialog entfernst, bekommst du natürlich völlig falsche Ergebnisse, da der essentiell ist für die Funktion des Checks. Die Exceptions des Tests interessieren nicht, da es nur ein Test ist, da wird bewusst in Kauf genommen, dass es Fehler gibt, die müssen nichts ins Log geschrieben werden.uzi hat geschrieben:ääähm... jaa... das ist ja auch kein wunder, dass da alles durcheinander geht. checkConnection ruft checkConnection(final URL url) auf, wo der thread gestartet wird. sprich: alle 4 urls werden parallel geprüft. das ergebnis wird dann in eine einzige instanz-var geschrieben (private boolean mResult). mal ab davon, dass der zuriff darauf nicht threadsafe ist, wird das ganze ergebnis natürlich false, wenn der letzte schreibende zugriff false sagt. ich vermute, das wird in 99% der fälle die gescheiterte ssl-verbindung zu duckduckgo sein.
Interessanter Punkt, aber kann die Antwort nicht auch vom Proxy oder vom Router kommen. Dann bekommt man eine Antwort, aber die sagt eben nicht aus, dass eine Internetverbindung besteht.uzi hat geschrieben:hm... abgesehen davon ist natürlich die frage zu stellen, ob man überhaupt den response code auswerten muss. das soll ja ein connection-check sein und kein server-check. ist ist völlig unerheblich, mit welchem response code der server antwortet, solange überhaupt eine antwort kommt.
"First they ignore you, then they ridicule you, then they fight you, then you win." - Mahatma Gandhi
Unterstütze die Weiterentwicklung von TV-Browser
Unterstütze die Weiterentwicklung von TV-Browser
Re: 3.3.3 Keine Internetverbindung
Ich habe die Abfrage für mehrere URLs jetzt geändert, so dass die in einem Thread ablaufen.
"First they ignore you, then they ridicule you, then they fight you, then you win." - Mahatma Gandhi
Unterstütze die Weiterentwicklung von TV-Browser
Unterstütze die Weiterentwicklung von TV-Browser
Re: 3.3.3 Keine Internetverbindung
...die darauf wartet, dass alles threads fertig sind. ändert nichts an der tatsache, dass jeder der 4 threads sein ergebnis in die gleiche var schreibt und damit der letzte 'recht hat'. wenn der false sagt, ist der check komplett false.Nein, so läuft das nicht ab. Die Methode checkConnection hat eine Warteschleife am Ende.
der dialog (sprich showDialog und auch hideDialog) greifen auf mResult gar nicht zu. die ändern daran also nichts.Wenn du einfach den Dialog entfernst, bekommst du natürlich völlig falsche Ergebnisse, da der essentiell ist für die Funktion des Checks.
die interessieren grundsätzlich schon. schon allein, weil man nicht in die zukunft gucken kann. ein log an- und abzuschalten bzw ein log-lvl zu ändern kann man jedem user zumuten. aber was in den sourcen nicht gelogt wird, kann man nicht auswerten. der tvb loggt imho grundsätzlich in jeder beziehung viel zu wenig, was die fehleranalyse schlicht unnötig kompliziert macht. ich hab nur 3, 4 zusätzliche log-ausschriften hinzugefügt und bin dem problem gleich deutlich näher gekommen.Die Exceptions des Tests interessieren nicht, da es nur ein Test ist, da wird bewusst in Kauf genommen, dass es Fehler gibt, die müssen nichts ins Log geschrieben werden.
hm. weiss ich nicht genau. eigentlich würde ich das nicht vermuten. aber wer weiss...Interessanter Punkt, aber kann die Antwort nicht auch vom Proxy oder vom Router kommen. Dann bekommt man eine Antwort, aber die sagt eben nicht aus, dass eine Internetverbindung besteht.
Re: 3.3.3 Keine Internetverbindung
Nein, die nächste URL wird ja erst geprüft, wenn entweder die Warteschleife abgelaufen ist oder der Test für die URL beendet ist. Die Methode gibt ja mResult als Ergebnis zurück und nur wenn das falsch ist, wird die nächste URL geprüft. Wäre das nicht so, würde ich nicht nach duckduckgo schon ein OK bekommen haben.uzi hat geschrieben:...die darauf wartet, dass alles threads fertig sind. ändert nichts an der tatsache, dass jeder der 4 threads sein ergebnis in die gleiche var schreibt und damit der letzte 'recht hat'. wenn der false sagt, ist der check komplett false.
Aber natürlich war das bisher schlecht programmiert, denn die URLs sollten eben alle in einem Thread geprüft werden, denn wenn die Warteschleife beendet ist, konnte das von dir beschriebene Verhalten auftreten.
"First they ignore you, then they ridicule you, then they fight you, then you win." - Mahatma Gandhi
Unterstütze die Weiterentwicklung von TV-Browser
Unterstütze die Weiterentwicklung von TV-Browser
Re: 3.3.3 Keine Internetverbindung
verwirrend. threading halt .
wie auch immer, ich habe noch ein wenig wegen der duckduckgo-exception geforscht. kann sein, dass die durch meinen code reingekommen ist. ich habe schlicht keinen proxy für https gesetzt gehabt:
solltest du vielleicht trotzdem auch im tvb-code mal prüfen, ob der proxy für beides gesetzt wird.
wie auch immer, ich habe noch ein wenig wegen der duckduckgo-exception geforscht. kann sein, dass die durch meinen code reingekommen ist. ich habe schlicht keinen proxy für https gesetzt gehabt:
Code: Alles auswählen
System.setProperty("http.proxyHost", xxx);
System.setProperty("http.proxyPort", xxx);
System.setProperty("https.proxyHost", xxx);
System.setProperty("https.proxyPort", xxx);
Re: 3.3.3 Keine Internetverbindung
TV-Browser setzt folgendes:
Code: Alles auswählen
System.setProperty("http.proxyHost", httpHost);
System.setProperty("http.proxyPort", httpPort);
System.setProperty("http.proxyUser", httpUser);
System.setProperty("http.proxyPassword", httpPassword);
System.setProperty("https.proxyHost", httpHost);
"First they ignore you, then they ridicule you, then they fight you, then you win." - Mahatma Gandhi
Unterstütze die Weiterentwicklung von TV-Browser
Unterstütze die Weiterentwicklung von TV-Browser
Re: 3.3.3 Keine Internetverbindung
https.proxyPort muss ich in meinem test-prog auch setzen, sonst gibts die besagte exception. user kann ich nicht testen, mein proxy hier ist ohne anmeldung. aber es steht ja zu vermuten, dass der ebenfalls eingetragen werden muss für https.