NSURL连接超时
我正在发送同步请求并收到错误,
NSData *aResponseData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&aResponse error:&anError];
Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo=0x6ede3d0
这可能是什么原因? NSURLConnection 的默认超时是多少?我可以打印这个值吗?
I am sending a synchronous request and getting a error
NSData *aResponseData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&aResponse error:&anError];
Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo=0x6ede3d0
What could be the reason for this? What is the default timeout for NSURLConnection? Can I print this value?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否检查过以确保能够在浏览器中或使用某种工具(例如curl 或wget)连接到该URL?从您正在测试的设备(或模拟器)上的 Safari 来确保这不是某种网络问题怎么样?
您可以通过使用 requestWithURL:cachePolicy:timeoutInterval: 类方法。
Have you checked to make sure you're able to connect to the URL in a browser or using a tool of some sort (e.g. curl or wget)? How about from Safari on the device (or simulator) you're testing on just to make sure it's not a network issue of some sort?
You can specify a timeout value by creating your NSURLConnection using the requestWithURL:cachePolicy:timeoutInterval: class method.
我认为连接由于服务器而超时(因为错误不一致)...我建议处理此错误并尝试再次发送请求..
重试 2 或 3 次,有一点延迟 --应该会在很大程度上帮助你......
I think the connection is getting timed out due to the server(since error is not consistent) ... I suggest handle this error and try to send the request again ..
do a retry for 2 or 3 times with a small delay -- should help you in great level ...