Hello,
Part of one of my apps posts data to a ASP.Net WebApi endpoint. While connected to WiFi, this works perfectly well. However, when on mobile data I receive:
Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo={NSUnderlyingError=0x1c40590e0 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={_kCFStreamErrorCodeKey=-4, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=https://rfrecycling.ltd.uk/api/NewApi/Session, NSErrorFailingURLKey=https://rfrecycling.ltd.uk/api/NewApi/Session, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-4, NSLocalizedDescription=The network connection was lost.}The post request is performed using URLSession.shared.dataTask(with: Request) in swift. When connected to Wifi, or in the simulator, this works flawlessly. So, I am confident that the data and request code are correct. The body of the request is json data, which is around 3k (so, relatively small). I have a similar GET request, that receives a large amount of data, that takes several minutes to complete, and this works fine. Therefore, it seems that the issue is related to the POST request.
The server is running IIS 8, and the endpoint is Asp.NET WebAPi v2. Again, I'm confident in this code, as it works perfectly well over WiFi. Yet when the endpoint is hit using mobile data, the server logs report a 500 error (though this isn't returned to the app, only the error message above).
I have spent many hours searching for a solution to this. I have found many results relating to caching etc. However, nothing I try will fix this.
Has anyone come across this issue, and more importantly, can anyone suggest a fix?
Due to the size of the data, I have all but ruled out timeouts etc.
Any thoughts or suggestions on this would be gratefully received.