Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

debug messages

  • Loading branch information...
commit 4b6546ca19c5f053c612269fe59b7a9e66e4f001 1 parent 66f6b2a
devendram devendram authored
Showing with 25 additions and 5 deletions.
  1. +25 −5 java/3.3/src/com/pubnub/api/Pubnub.java
30 java/3.3/src/com/pubnub/api/Pubnub.java
View
@@ -187,7 +187,10 @@ private Request getRequest(List<String> url_components, int requestTimeout) {
rb.addHeader("V", "3.3");
rb.addHeader("User-Agent", "Java");
+
+ //Disabling gzip
//rb.addHeader("Accept-Encoding", "gzip");
+
rb.setUrl(url.toString());
if (requestTimeout > 0) {
@@ -578,7 +581,7 @@ private void _subscribe(HashMap<String, Object> args)
callback.disconnectCallback(channel);
} else {
subscriptions.remove(it.channel);
- callback.errorCallback(channel,
+ callback.errorCallback(channel, response.optString(1) + " " +
"Lost Network Connection");
}
}
@@ -618,6 +621,7 @@ private void _subscribe(HashMap<String, Object> args)
}
}
}
+
JSONArray messages = response.optJSONArray(0);
// Update TimeToken
@@ -663,7 +667,11 @@ private void _subscribe(HashMap<String, Object> args)
}
}
}
- } catch (Exception e) {
+ }
+ catch (JSONException e) {
+ e.printStackTrace();
+ }
+ catch (Exception e) {
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {
@@ -966,7 +974,10 @@ public void unsubscribe(HashMap<String, Object> args) {
*/
private JSONArray _request(PubnubHttpRequest phr) {
String json = "";
- System.out.println(phr.request());
+ System.out.println();
+ System.out.println("URL" );
+ System.out.println( phr.request());
+ System.out.println();
try {
// Execute Request
Future<String> f = ahc.executeRequest(phr.request(),
@@ -974,6 +985,14 @@ private JSONArray _request(PubnubHttpRequest phr) {
@Override
public String onCompleted(Response r) throws Exception {
+ System.out.println();
+ System.out.println("RAW RESPONSE");
+ System.out.println("========");
+ System.out.println(r.getStatusCode() + " " + r.getStatusText());
+ System.out.println(r.getHeaders());
+ System.out.println(r.getResponseBody());
+ System.out.println("========");
+ System.out.println();
String ce = r.getHeader("Content-Encoding");
InputStream resulting_is = null;
@@ -1004,7 +1023,7 @@ public String onCompleted(Response r) throws Exception {
}
reader.close();
- System.out.println(json);
+ System.out.println("Decompressed Response : " + json);
return json;
}
});
@@ -1033,7 +1052,8 @@ public String onCompleted(Response r) throws Exception {
try {
return new JSONArray(json);
} catch (JSONException e) {
- return new JSONArray().put("Error: Failed JSON Parsing.");
+ e.printStackTrace();
+ return new JSONArray().put("0").put("Error: Failed JSON Parsing.");
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.