ErrorDomain =NSURLErrorDomain Code=-1001 “request timeout.” UserInfo={NSUnderlyingError=0x1c0a48310 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 “(null)” UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}
For this reason, I have checked for a long time. There are many posts setting timeout on the Internet. However, this GET request returns this error without timeout. Here is an introduction to encoding usage scenarios
JSONEncoding. Default is placed in HttpBody, such as post requests
2. URLEncoding. Default is concatenated address in GET, such as GET request
3. URLEncoding(destination:. MethodDependent) is a custom URLEncoding. If the value of methodDependent is in GET, HEAD, and DELETE, it will be concatenated. The other methods are in the httpBody.
4. URLEncoding(destination:.httpbody) is placed in httpBody
So I replaced the previous JSONEncoding. Default with URLEncoding. Default
Alamofire.request(url, method: .get, parameters: nil, encoding:JSONEncoding.default, headers: [“Content-Type”:”application/json”]).responseJSON { (response) in
}
Alamofire.request(url, method: .get, parameters: nil, encoding:URLEncoding.default, headers: [“Content-Type”:”application/json”]).responseJSON { (response) in
}
For this reason, I have checked for a long time. There are many posts setting timeout on the Internet. However, this GET request returns this error without timeout. Here is an introduction to encoding usage scenarios
JSONEncoding. Default is placed in HttpBody, such as post requests
2. URLEncoding. Default is concatenated address in GET, such as GET request
3. URLEncoding(destination:. MethodDependent) is a custom URLEncoding. If the value of methodDependent is in GET, HEAD, and DELETE, it will be concatenated. The other methods are in the httpBody.
4. URLEncoding(destination:.httpbody) is placed in httpBody
So I replaced the previous JSONEncoding. Default with URLEncoding. Default
Alamofire.request(url, method: .get, parameters: nil, encoding:JSONEncoding.default, headers: [“Content-Type”:”application/json”]).responseJSON { (response) in
}
Alamofire.request(url, method: .get, parameters: nil, encoding:URLEncoding.default, headers: [“Content-Type”:”application/json”]).responseJSON { (response) in
}
Read More:
- request:fail url not in domain list or Cannot send network request to localhost
- Four ways to get Django parameters in request
- In the HTML page request Ajax times 400 error, solve Yii submit post form 400 error, and Ajax post request 400 problem (example code)
- Flask Request an extension before_request after_request errorhandler
- [nodejs] error request aborted after request routing in post mode
- IIS “Bad Request – Request Too Long. HTTP Error 400. The size of the request headers is too long.”
- WebView loadrequest request request error “nsurlconnection finished with error – Code – 1022”
- The problem that headers [‘content-type ‘] does not work is set in the Axios get method request interface
- Error: timeout of 5000ms exceeded error is always reported during post request
- GeTx reports an error in the get request using getconnect
- Real machine debugging error error = = error domain = nsurlerrordomain code = – 1009 “seems to have disconnected from the Internet. “
- Nginx modifies the front end request size limit (413 request entity too large)
- Error in v-on handler (Promise/async): “Error: Request failed with status code 500“
- TypeError: Failed to execute ‘fetch‘ on ‘Window‘: Request with GET/HEAD method cannot have body.
- Error: request failed with status code 500
- Bad Request – Request Too Long. HTTP Error 400. The size of the request headers is too long
- Request cannot get static resource
- An error occurred while processing your request
- Asynchronous Future Parallel processing request code example
- docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled