Geofencing : HTTP request failed while sending through the background service. Gives UnknownHostException

前端 未结 5 690
天命终不由人
天命终不由人 2021-02-05 12:48

I implemented Geofence in android application. I followed this link to implement \'Geofence\' in app. I am using \'Retrofit\' library to call \'HTTP\' request.


Ap

5条回答
  •  面向向阳花
    2021-02-05 13:04

    I had the same problem: "java.net.UnknownHostException: Unable to resolve host "host_name": No address associated with hostname". Also Internet was available with all granted Android permissions (tested them all even at runtime).

    But the solution was different. The reason was that our API-host "host_name" (e.g. http://xxx.yyyy.zz) was in LAN and was not able from outer network. The same issue may be caught if you are calling your company's outer "host_name" from company's LAN (it seems like "DNS Rebind attack" for server). To test it you should try to open used url in a browser when the device is (and when isn't) connected to Internet from a local LAN (e.g. company's Wi-Fi) and check if server response is correct.

    The @Mangesh Sambare's problem was solved as he said above, but maybe this experience'll be helpful for somebody who're in the same situation as I was.

提交回复
热议问题