The app does not work with 3g connection, but works great on Wi-Fi

Adhoc is a deployed application on the device, the application works fine with Wi-Fi, but does not work with a 3g connection. Any idea what I am missing?

Do not get much help from google.

Also, the installed application does not appear in the "Use mobile data for: list

The code:

    //To handle time out issue with 3g

    configuration.timeoutIntervalForResource = 60

    // Mark using Alamofire to do the downloads

    self.alamofireManager = Alamofire.Manager(configuration:configuration)
    self.alamofireManager!.request(.GET, jsonUrl).responseJSON(){
        (_, _, JSON, _) in
        println("printing json :\(JSON)")
        if JSON != nil {

              let imageInfos = (JSON!.valueForKey("image") as [NSDictionary]).map {
                ImageInfo(id: $0["id"] as String, url: $0["url"] as String)
            }

           self.tableData.addObjectsFromArray(imageInfos)
 }

Error Log:

I get

(Error Domain = NSURLErrorDomain Code = -1004 )

no matter how much I increase timeoutInterval. I tried both with the resource and with the request

I forgot to mention that the server was a raspberry Pi, and I could not access the server outside the local network, which caused the problem. Thanks for the help. The timeout was very useful when processing server errors.

+4
3

, Wi-Fi 3G. request timeout. , .

+1

, - , .

var alamofireManager : Alamofire.Manager?

func getCallToServer(){
  let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
  configuration.timeoutIntervalForResource = 10 // seconds

  self.alamofireManager = Alamofire.Manager(configuration: configuration)
  self.alamofireManager!.request(.GET, "http://example.com/")
    .response { (request, response, data, error) in

    }
}
0

, , , , , , , -

0

Source: https://habr.com/ru/post/1584251/


All Articles