I tried to access the rest api call URLSession in the swift and server side AKKA framework used. I am getting 503 error frequently. I have searched lot thing and most of result says it's server side issue. I have tested in postman and JMeter concurrent test cann't face any issue (error code 503). I hope 503 getting not because of sever side issue.
let headers = ["content-type": "application/json",
"access-token": "3ccecc61-1fc5-4f54-88d5",
]
let parameters = [
"s3url": "https://s3-us-west-1.amazonaws.com/image.png",
"gender": 1,
"userid": 22,
"username": "sample"
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "http://ec2.compute-1.amazonaws.com/generate-image")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
ios response
dataTaskWithRequest HTTP status code: 503
dataTaskWithRequest HTTP response code: <NSHTTPURLResponse: 0x17043f160> { URL: http://ec2.amazonaws.com:9000/image } { status code: 503, headers {
"Content-Length" = 105;
"Content-Type" = "text/plain; charset=UTF-8";
Date = "Mon, 18 Sep 2017 15:01:41 GMT";
Server = "akka-http/10.0.0";
} }