I get network errors running on android. These do not appear in simulator or ios builds. The errors appears about 75% of the time and then will work correctly for one time. I did some debugging and the network call returns a 0 for response code and null for response content.
I've attached the call below for my get command. This code has not changed in many years (3?). I tried 2 different applications now and both exhibit the same behavior.
I've tried going back to older builds but my 'pro' license only allows me to go back to 1 latest???
I know its not the server as it works for iOS and simulator and 2 different application. I have been unable to figure this out.
An suggestions? I tried to use the new Rest, but it doesn't find the class (i went to latest).
public int doGet(final String url) {
if ( Display.getInstance().isEdt() ){
Log.e("*** Performing a GET network call on the EDT");
}
final ConnectionRequest request = new ConnectionRequest() {
@Override
protected void handleException(Exception err) {
if (Dialog.show("Connection error",
"Check your internet connection", "Retry", "Exit")) {
Display.getInstance().exitApplication();
} else {
retry();
}
}
};
request.setUrl(url);
request.setPost(false);
request.setFollowRedirects(false);
request.setReadResponseForErrors(true);
request.setSilentRetryCount(1);
request.addResponseCodeListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Log.d("Response code ResponseCodeListener, setting to -1");
responseCode = -1;
}
});
request.addResponseListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
Log.e("Response listener action for GET performed " );
ConnectionRequest cr = (ConnectionRequest) evt.getSource();
responseCode = cr.getResponseCode();
Log.e("Response listener action for GET performed: " + cr.getResponseCode() );
if (cr.getResponseCode() == 200) {
responseData = new String(cr.getResponseData());
} else {
Log.e("Response code: " + cr.getResponseCode() + " of " + cr.getUrl() );
}
}
});
// request will be handled asynchronously
NetworkManager.getInstance().setTimeout(15000);
synchronized (lock) {
depth++;
}
try {
request.setDuplicateSupported(true);
NetworkManager.getInstance().addToQueueAndWait(request);
} finally {
synchronized (lock) {
depth--;
}
}
Log.d("Response: {0} {1}", responseCode, responseData);
return responseCode;
}
Log entries: 02-11 10:08:26.932 20250-20326/? D/Word Time: [Thread-18] 0:0:2,486 - Get: /jgame/game/6647?tkn=08F0D0B4E7EE80370B982DBEA261500ADB53266C1847175152-1461100
02-11 10:08:26.933 20250-20326/? D/Word Time: [Thread-18] 0:0:2,488 - Calling: GET http://server.wordtimelive.xyz/jgame/game/6647?tkn=08F0D0B4E7EE80370B982DBEA261500ADB53266C1847175152-1461100
02-11 10:08:26.934 20250-20326/? D/Word Time: [Thread-18] 0:0:2,489 - Get: http://server.wordtimelive.xyz/jgame/game/6647?tkn=08F0D0B4E7EE80370B982DBEA261500ADB53266C1847175152-1461100
02-11 10:08:27.207 20250-20326/? D/Word Time: [Thread-18] 0:0:2,762 - Response: 0 null
02-11 10:08:27.209 20250-20326/? D/Word Time: [Thread-18] 0:0:2,763 - content null of GET: http://server.wordtimelive.xyz/jgame/game/6647?tkn=08F0D0B4E7EE80370B982DBEA261500ADB53266C1847175152-1461100