1
json-rpc
을 retrofit2
을 통해 보내려고했습니다. 이 내 인터페이스 :retrofit2를 통해 Json-rpc을 보내는 방법?
public interface ApiInterfaceJson {
@POST
@Headers("Content-Type: application/json")
Call<String> getDataJson(
@Url String url,
@Body RequestBody body);
}
이 retrofit
만들기 :
retrofitJson = new Retrofit.Builder()
.addConverterFactory(ScalarsConverterFactory.create())
.baseUrl("http://localhost:8800")
.client(client)
.build();
apiInterfaceJson = retrofitJson.create(ApiInterfaceJson.class);
전화 :
JSONObject paramObject = new JSONObject();
try {
paramObject.put("id", "0");
paramObject.put("name", "user");
paramObject.put("command", "finish");
}catch(Exception e){
}
RequestBody requestBody= RequestBody.create(MediaType.parse("application/json"), paramObject.toString());
MinersMonitorApplication.getApiJson().getDataJson("http://10.10.10.230:10000", requestBody).enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {}
@Override
public void onFailure(Call<String> call, Throwable t) {
}
});
결과는 SocketTimeoutException
입니다.