0

I have a client/server application where the client is an iOS app and the server is a RESTful api. I have received complaints of requests timing out and I know that some/most of the time, this is due to poor wifi connectivity. In these situations I would like to display an error message on the client which indicates whether the request was received by the server.

Is it possible in iOS to tell the difference between a HTTP request that never reaches the intended destination and one that makes it all the way to the intended destination but never receives a response?

nzhenry
  • 752
  • 8
  • 15
  • may be your data is high – Anbu.Karthik Mar 03 '17 at 06:27
  • i think you can't tell until you get a response from the server – Redhya Mar 03 '17 at 06:29
  • There is a case that happens when you are connected to the internet but the speed you get 0 kb/sec or something. So reachability still sees it as being connected to the internet but you simply don't receive the speed. In this case only after a long while do you get a *timeout* error. – Rikh Mar 03 '17 at 06:31

1 Answers1

0
  1. API Call only after you check whether your internet connectivity is reachable or not .show error message if not connected to internet(this is due to poor wifi connectivity)

    Example : Check for internet connection availability in Swift

  2. When its checked make api call handle error code 404(never reaches the intended destination) and 504(timeout error code never receives a response) and let user make it success only when status code is 200.But its good to handle 401(authorization error) also.

I don't know which library you are using that why can't provide any code example right now

Try Alamofire Library in swift I suggest handled error codes very well.

Community
  • 1
  • 1
Ravindra Shekhawat
  • 4,275
  • 1
  • 19
  • 26