NSXMLParser - the request timed out - iphone

I have been intermittently receiving a "The request timed out" message via the NSXMLParser parseError method. (NSError)
It doesn't happen in the simulator only on the actual device. (i4)
On the device it usualy happens when the app being launched the first time.
Once I have the first parse done (after one or two app restart) every other web service call will work just fine.
I can then restart the app as many times as I want it won't show the error anymore.
I don't see how this is a timeout error as the app won't hang up. The error pops up instantly.
Any idea?
Thank you

I could never figure out this error. It looks like this message appears only when the connection is very slow.

Related

Run under debug using a real device

I don't understand how to view the debugged app on a real device. To begin with, I see such a picture, it lasts about 3-5 minutes.
And then I get an error -
Waiting for a connection from Flutter on M2003J15SC... Error
connecting to the service protocol: Exception: connection to device
ended too early
I put dots in the code, and it is important for me to know what is happening there at the time of execution, so I need a debug mode. Help please, what am I doing wrong?

iPhone app loses internet connectivity (NSURLConnection not returning)

I'm having an issue that's incredibly hard to debug. If my app is using WiFi and it sits idle for around 30 minutes, sometimes when I wake it up, the NSURLConnection no longer responds. Requests are sent, but never return.
At first, I thought this was a memory bug with the instances being released too early and thus never returning a response. However, if I put the app in the background, go into settings, turn off WiFi so 3G is used exclusively, and return to the app, the internet connection magically comes back to life and all pending NSURLConnections return and complete.
Obviously this is an issue for people using WiFi. Is this really a WiFi issue, or am I missing something? Going to another app like Safari, using the WiFi radio and returning to my app doesn't solve the problem - connections still don't return. I've traced this with Xcode and I'm running out of ideas.
Also 'Application Uses WiFi' Info.plist flag is set to ON and this is firmware 5.1.
is 'Application Uses WiFi' the same as UIRequiresPersistentWiFi?
Update: This has nothing to do with the Wifi flag - it can die within 5 minutes. So far, I've only been able to duplicate it on my iPhone 4s with 5.1 firmware. It's not really a solution, but I'm erasing the phone to try it with a fresh install to see if that has any effect. I have verified that NSURLConnection is always called on the main thread, and set breakpoints at connection:failedWithError: and connection:didReceiveResponse:. When the connection dies, none of these return until I disable and re-enable WiFi, and then all return at once. This happens on a local server as well, and the server still returns if I ping it with a web browser.
For any others running into this issue, it's due to TestFlight v1.0 and below:
Why does NSURLConnection fail to reach the backend?
Are you actually transmitting/receiving any data through the NSURLConnection? If not, is it possible you are hitting a TCP session timeout? Seems unlikely if the problem persists on a local server, but any intervening stateful firewall/packet inspector might be casting off your TCP connection.

Flicker TimeStamp

When i try autotization on flicker i get error
org.lukhnos.ObjectiveFlickr Code=2147418116 "The operation couldn\u2019t be completed.
(org.lukhnos.ObjectiveFlickr error 2147418116.)" UserInfo=0x4c9000
AuthError=oauth_problem=timestamp_refused
I try this how to realise the new OAuth when using objectiveFlickr on mac app but all link is broken
Who can help me with that problem?
Make sure that your device time is set properly. If it's not, it will give the specified error message. Basically it's related to your device time and server time. If you set the device time to existing time it will work as expected.

NSURLConnection - didFailWithError not invoked

I am using NSURLConnection to load data from server. So, in my Iphone Application had a button, when click on this button and internet connection is connected, the data will be loaded successfully. But later when I switched off the internet connection on Mac, and then click on that button again, the didFailWithError method does not invoked but other methods such as didReceiveResponse, connectionDidFinishLoading was get called.
Anyone encountered this kind of problem before? Or anyone know the reason of this problem?
Really appreciate for any comments, suggestions and solutions. Thanks.
Before changing any line in your code, try the same test with 4.3 simulator and then 5.0.
I've tried something similar (request to URL and connection is closed with no response), and using 4.3, didFailWithError is called. In 5.0, I get a didReceiveResponse with a status code 200 OK (!) and then connectionDidFinishLoading. Same code, same request, different OS versions...
Strange behavior especially because you turned internet off, but delegate still called for ** connectionDidFinishLoading** how this is possible? Also you wrote what "when click on this button and internet connection is connected" your code still initiated connection without internet?
It's possible, what you configured using of cached data and thats why you got strange behavior like this.
*nix systems by default have timeout for connection on BSD sockets which may don't tell you nothing about what connection is missed. But i think Mac OS/iOS configured for this kind of case.

AsyncUDPSocket broken pipe after locking phone with application suspended in background

I'm using the AsyncUDPSocket third party library in my iPhone app and for the most part it works great. I have a singleton instance of an AsyncUDPSocket that I use for all my network traffic. My app is registered for location tracking in the background and will wake up and send location update packet(s) over the network while running in the background. This all works smashingly running in the background, foreground, phone locked or unlocked, except when I do the following:
Start my app
Disable location tracking in my app settings
(so no background waking up)
Press the home button (app goes into background, socket is "freeze-dried" with rest of app)
Lock phone
Unlock phone
Resume app
Attempt to restart tracking and send something out the socket. As soon as I try, I get a SIGPIPE/EPIPE error and the app crashes.
I figured the best way to deal with this would be to close and release the socket whenever the application exits and background tracking is not enabled, but when I try [socket close] or [socket release] on the AsyncUDPSocket, I get various EXC_BAD_ACCESS errors. I've filed a bug with the dev team, but was wondering if anyone here could give some ideas on how to either avoid the SIGPIPE error entirely or other ways to keep the socket alive without releasing it. Thanks.
Great observation - yes, seems that after you send task to background and then lock the phone, sockets get dropped and next time you try to use it one gets bludgeoned with a SIGPIPE.
Ideas on how to deal with it here:
SIGPIPE crash when switching background task
(it's either set ignore for SIGPIPE for the whole app, or for the socket, or provide hanler for it)
ps. also - seems that setting to ignore SIGPIPE does not work with attached debugger, so compare with and w/o.
Just in case anyone's curious (which, judging by this question's stats, they're not), I was not able to determine what was causing the SIGPIPE error, but did eventually sort out my memory management issues (which were due to a faulty implementation of onUdpSocketDidClose in my delegate) so that I am able to reinitialize the socket each time the app restarts.