I am deployed my rails server on EC2 instance and I am trying to get data from server using http requests (for that I am using okHttp. But I am facing some connection issue in some devices. I tried finding out the issue but still unable to do it.
kotlin code:
val client = OkHttpClient()
val body = FormBody.Builder().build()
// to create url I am using server IP directly without any port
val urlNetworkCheck = Constants.URL_CHECK_NETWORK_CONNECTION // http://10.40.21.16/api/v1/check_network
val requestNetworkCheck = Request.Builder().url(urlNetworkCheck).post(body).build()
client.newCall(requestNetworkCheck).enqueue(object: Callback {
override fun onResponse(call: Call, response: Response) {
val responseNetworkCheck = response.body?.string()
logger.info { "Network connection is present." }
}
override fun onFailure(call: Call, e: IOException) {
logger.info { "Could not connect to server. Exception: " + e.message }
runOnUiThread {
showToast(Constants.TOAST_NETWORK_ERROR)
}
}
})
On many devices, TOAST_NETWORK_ERROR is being shown. Please let me know what could be wrong here.
Update: Exception: CLEARTEXT communication to 18.224.2.107 not permitted by network security policy is what I am getting.