I have an app on the appStore that syncs xml data to a webservice. I've had two error reports today caused by the xml document ending prematurely. One ended right in the middle of an xml tag, so I know it isn't a problem caused by special characters. One of the errors occurred at 184kb, the other at 302kb, so it's not a problem with the request being truncated after so many bytes. It does seem to only be a problem on longer requests though.
Are there any specific settings that will prevent this truncation from happening?
I've been able to reproduce this by shutting down my app before the NSURLConnection finishes sending the request. I'm guessing the same thing was happening with a couple of my app users.
Related
I'm using a library to download media. The download function returns a stream. Occasionally, partway through the download, an error occurs in one of the http requests used to yield each item of the stream.
When such an error occurs, I'm currently discarding the entire download and retrying from the beginning. Without being able to change the library's code, is it possible to retry the last item in the stream, so the http request can be retried again and the download can continue from there?
I realize this is probably impossible since the library's state would need to somehow be rewinded to before the error occurred. But maybe someone has a suggestion for how I can handle library errors like these that might happen many minutes into downloading a large file, and take advantage of the fact that I already have all the data successfully downloaded up to the point of the error.
I have weird issue running the last version of Raknet on iOS with Unity3D: I get CONNECTION_ATTEMPT_FAILED when trying to connect to the server.
Now let's me detail the issue:
he exact same Library connects fine when used in an ObjectiveC application, so the issue seems to be Unity3D related.
I already managed to pinpoint my issue to be located in Raknet reliability layer:
Apparently, during the last step of the connection process (when the connection handshake as been completed) the reliability layer of the server thinks that the ID_CONNECTION_REQUEST packet received from the client is an acknowledgment instead of a message. Therefore it doesn't answer. Ultimately after a few tries, (and a 10s timeout) the client fails with the CONNECTION_ATTEMPT_FAILED error.
Does anybody there as an idea? I will update the question when I manage to get more info.
Update
We are using Unity3D 5.1.1f1
We managed to find a workaround! See answer for more information. As the workaround doesn't tell us much about what really happened, I would gladly hear some C++/XCode/Unity/iOS/AppleLLVM6.1 experts around here explain what really happened.
The issue was that the Raknet header wasn't properly generated by the iOS client. Namely we were sending ACK messages in place of simple packets. The rest of the message was considered as garbage by the server and the packet was dropped. The client kept trying to send the corrupted handshake packet a few times before timeouting.
This doesn't tell us why, doesn't it? Apparently the serialize method of the class DatagramHeaderFormat wasn't called as it should have been when running Raknet in Unity (iOS). Something else (and I don't know what) was linked in place of this method and was filling the BitStream with a corrupted header.
I am quite sure that the serialize method wasn't called because printf calls from inside weren't displayed in the console.
We renamed DatagramHeaderFormat::serialize into DatagramHeaderFormat::serializeHeader and... voila, it works.
Now I only want to understand what did the compiler (and why).
I am running into out of memory issues after a certain amount of time when I run my quickfixj app. After a little investigation I found out that this was being caused by messages that quickfixj caches for re sending when a resend request is received.
So for testing I set this flag to N on a particular session. After that my memory problems completely disappeared. But I do not understand why quickfixj is keeping these message in memory when I have properly set this property : FileStorePath. These messages should be stored into a file but they are not. I do see some files present in the directory I set in FileStorePath but none of them seems to be storing messages, I can only see sequence number in them. Do I need to set other flags besides this in order to make this work?
I do not plan to use PersisMessages flag outside testing. I would prefer FileStoreMaxCachedMsgs flag with a reasonable figure. I also need to know what will happen if my app receives a resend request when I have set PersisMessages to N? Will quickfixj send gapfills instead or will it crash with some exception message?
Thanks
i ve found that quickfixj sends gap fills when it could not find messages. also the config flag FileStoreMaxCachedMsgs is used to tell quickfixj about how much messages it should keep in cache before pushing them down to files. so this flag, in my opinion, should be altered in order to get your app to work without running out of memory due to message caching.
hope it ll be helpful for somebody. Thanks
I've got an iOS application, and we've been getting some errors that seem to be related to encoding problems because some of content is getting truncated when it reaches the server. This is problematic because it's been messing with our authentication mechanism, which involves making a hash of the posted content (along with some other stuff, but that's the basics).
So far we haven't been able to reproduce the problem locally. We have a theory that it's related to something like, an emoji keyboard; but I've tried posting emojis, international characters, everything that I could think of. Everything gets posted correctly when I try it. I know that there was a difference in the way ios encodes emoji between ios 4 and 5; we've managed to speak with a few of our customers to try to get an idea about what they're using, and it's usually iOS 6, with either an iphone 4s, or 5 (just like our test devices, I've tested with ios 5 and 6) ... so it wouldn't seem to be related to the OS.
This is how we are setting the request's body for the post.
[req setHTTPBody:[paramString dataUsingEncoding:NSUTF8StringEncoding]];
Previously, I was just setting the content-type to this:
[req setValue:#"application/x-www-form-urlencoded" forHTTPHeaderField:#"Content-Type"];
And my theory is that being explicit about the charset in the content type might fix it:
[req setValue:#"application/x-www-form-urlencoded; charset=UTF-8" forHTTPHeaderField:#"Content-Type"];
So my question for you SO, is this crazy? do you think being explicit in setting the charset to UTF-8 would resolve the issue? Any other troubleshooting techniques that you can recommend to figure out where the problem is occurring?
Do you have a wireshark or fiddler trace of a failing request? I would start there to verify that the client is indeed sending truncated data, and it's not a server side issue.
Check that the Content-Length header is correct regardless of data sent. Since the issue is not easily reproducible, perhaps collect more specific data from users who saw the problem, so the problematic inputs can be identified, and the broken request can be reproduced repeatedly.
I doubt it's an encoding issue if you are pulling strings straight from a UITextField, you shouldn't have encoding issues. If you are going to/from CStrings or NSData then that would be the first place to check.
Not a conclusive answer by any means, but that's where I would start.
I am using Nokogiri for parsing XML.
Problem is in response time of external resource. Sometimes it works fine. Sometimes respond time can be over 30 seconds. Sometimes it returns different error codes. What I need is to find out the fastest way to know if my XML is ready to be requested by open-uri. And only then to make actual request.
What I am doing now is setting Timeout to 5 seconds to prevent delays.
begin
Timeout::timeout(5) do
link = URI.escape("http://domain.org/timetable.xml")
#doc = Nokogiri::HTML(open(link))
end
rescue Timeout::Error
#error = "Data Server is offline"
end
For checks at the level your code shows, you'll need cooperation from the remote service, e.g., conditional HEAD requests and/or Etag comparison (those together would be my own preference.) It looks like you may have some of this as you say it sometimes returns error codes, though if the those error codes are in the XML payload they're not going to help and of course, if the remote service's responsiveness is variable it will probably fluctuate between your check and subsequent main GET request.
FWIW: if you're just looking to improve your app's responsiveness when using this data, there are cache approaches you can use, e.g., use a soft-TTL lower than the main TTL that, when expired, causes your cache code to return the cached XML and kick off an async job to refetch the data so it's fresher for the next request. Or use a repeating worker to keep the cache fresh.