Client to receive data from a Server-Push

1

I am trying to create a client to consume data from an interface which receives data from a gateway. This interface implements a server-push that needs to be started from a PUT request made by the client. After the request returns 200, the interface should start sending the data to the path / rest / callback / payloads / ul as soon as the data arrives.

In the request, log data is sent from my application so that the interface directs the push to the registered application, the Requisicao.java file is as follows:

JsonObject json = new JsonObject();

json.addProperty("host", "http://myhost");
json.addProperty("port", 443);
json.addProperty("path_prefix", "/Omni/servlet");
json.addProperty("auth_string", "Basic " + "user:pass");
json.addProperty("retry_policy", 0);
json.addProperty("data_format", "base64");

Gson gson = new Gson();
String json_string = gson.toJson(json);

URL url = new URL("https://server.orbiwise.com/rest/pushmode/start");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();

conn.setRequestMethod("PUT");
conn.setRequestProperty("Authorization", "Basic " + "user:pass");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Access-Control-Allow-Origin", "*");

conn.setDoInput(true);
conn.setDoOutput(true);
conn.connect();

OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream());
out.write(json_string);
out.close();

if (conn.getResponseCode() == 200) {
    System.out.println("SUCCESS!: " + conn.getResponseCode());
} else {
    System.out.println("ERROR: " + conn.getErrorStream() + conn.getResponseCode() );
}

The request is already returning OK and to receive the push data I used a Servlet with path equal to what the interface documentation requests ( / rest / callback / payloads / ul ). But the data is not coming to him. If you can help me or give you a simpler way to receive this data, I would appreciate it.

    
asked by anonymous 04.12.2018 / 16:50

0 answers