I have an app on iphone and android that both fail periodically when calling the server. When I say that they fail I mean that I get no errors codes, 200 Connection code meaning that it was successful, but a corrupted string/data/(jsonObject/Array). I list all of those data types because depending on the app they use some or all of them. The information when printed out in sting form does have the return JSON coming from the server, but it is corrupted with extra code or text that will not allow JSONParsers to work properly. Like I said before it doesn't fail all the time and it only fails in what is in the returned string/json/data. I have been told before that I am connecting, receiving, and handling the information correctly and that I should look to the server. We have changed servers in the middle of this and it works faster but still has a similar fail rate. Also, the server does not fail or have issues with browsers. So, in all web browsers it throws no errors, doesn't corrupt the site and or the information that is displayed. So, if I get on my computer and go to the website I will see the correct information every time when I load the page. Any ideas would be greatly appreciated.
The answer that I found out for android was that it was the old server, but the new serve still had issues with the IOS app but I figured out that if you alloc the NSString with the NSData then the information will not have any possiblities of gaining extra data or information. So alloc works.
Related
Okay, weird, weird question time. I have an Android app that submits data to the server using a form POST to an ASP page. Well, at least it SHOULD. I actually have 2 domains. Let's say they are: MySite.com and MySiteBeta.com.
When I use the Android app and post to MySite.com the form data is received without any problems. When I modify the app to post to MySiteBeta.com the form data is not received. (No changes to the code except the domain name) Mind you, there are no errors recorded in the page - and execution continues past where any error should have occured. But, no form data is present. I'm looping through the Request.Form object just to be sure, and nothing is there. Also, if I just create another ASP page to send this form data, everything works fine. So, it doesn't seem to be anything with the ASP page itself.
What could cause an Android app to work when posting to one domain but not another? NOTE: The files on the server are the same. I'm assuming it may be some sort of permissions in the ASP setup (running IIS8)? Not sure.
I have just become a SHOUTcast partner and received my DevID.
I read pretty much everything here:
SHOUTcast_Radio_Directory_API
and here: SHOUTcast_API_License_Agreement
And I have a tough question: should I cache the results from their API calls?
If decided to cache, I would be going against what is requested in the SHOUTcast Radio Directory API:
Do not cache the XML for more than 1 day, as station ID's can and will change.
If I did not cache anything, I would be going against the SHOUTcast API License Agreement:
Please do not hammer the servers. We request reasonable usage and recommend that you utilize local caching.
Moreover, let's suppose I decide to cache results. Since those results are 100% based on users' queries, wouldn't it be somewhat silly to cache those results, as my app's users would probably enter different queries every time????
In an effort to try to solve my problem, I had the idea of downloading the entire SHOUTcast database, once a day/week, and then, upload it to my own server. Afterwards, my app would send all queries to my server, and wouldn't bother SHOUTcast's servers at all.
The problem with such an approach, though, is that I could not find a way to download the entire SHOUTcast database at once, like we can do with IceCast's dir.xiph.org/yp.xml.
What should I do next???? How should I proceed?
I'm afraid of hurting the SHOUTcast API License Agreement and getting my DevId revoked:
We reserve the right to revoke access for DevIDs which abuse the system.
Has anyone here ever created an application that connects to SHOUTcast's directory? If so, which approach have you used not to be banned?
Just for the sake of completeness, I will answer my own question with the solution I came up with.
After a lot of research I decided to create a 30-minute cache, from which I retrieve the last results. Should the user change the search filter, or should the cache expire, all cached results are cleared, a new request is made to SHOUTcast's servers and a new cache is created.
The code can be found here:
ShoutcastRadioStationList.java
RadioStationCache.java
Im not quite sure whether the problem is with my android program or its a some kind of limitation in the web server api. Im using futurerequest to get the data from xively with api key and feed id, and parsing the data in json format, then storing it in my db. The connection establishes just fine and im able to connect and get the data from the server. This is done through an asynctask and the request frequency is 1 min.
The issue im facing is that when i update the data in the server through web browser, the response on my program is not updated. It keeps getting the old data. When debugging i can clearly see that everything is working as intended, and i can see that the json response object i get from the server is working, however, the data is not fresh. I found out that by changing the api key manually makes the program get the newest data. Also by clearing the cache and data results in fetching the new data from the server. As you you know, i cant ask the user to clear his cache and data everytime to get the latest update.
How do i go about this issue? What might be the reason behind this problem? Thanks in advance!
Edit: Clearing the cache alone does not help. Also, using the phone instead of the emulator doesnt help either.
Im using volley library to handle the request/network traffic
Wanted to updated the solution that i found. This link helped me find the solution. Apparently, there is some caching involved by volley. By using the method
request.setShouldCache(false);
i was able to get the lasted updates from the server at all times.
However, when i tried to get the cache with the code below, before setting it to false, to see whats in the cache it was empty. entry would always be null. if someone know why and could explain i would be grateful :)
Entry entry = queue.getCache().get(url);
if(entry!=null){
String data = new String(entry.data, "UTF-8");
// process data
}
Below I explained what I need and in the answer I would like to get information what technology, what kind of protocols, services etc should I use.
Also I know that there is a massive amount of information on the internet, but because there are so many choices I'm unable to make a decision. Here's what I want to have:
Android application which will sent and receive information from the internet/server
Of course server, which will do some rudimentary computation with the obtained information, then store it and at the end send it back to the client application
I have to admit that the subjects of networking, socketing, protocols, ciphering etc are the ones I've always run away from. Therefore advices such as what domains, databases etc utilize are highly welcome
Update: After a bit of a research I've implemented mechanism based on information from this site [1]. I already have a working MySql database with several tables inside. Also I've added php scripts to my Apache webspace and implemented all that's necessary within my Android app.
Now, as I understand communication between php's scripts and MySql database is safe (I've hardcoded the usr/pass within scripts). Therefore the only thing that has left to be done to secure the connection between my Android application and php scripts (I want to prevent the situation when everybody has an access to my php scripts). So my question should be pretty straightforward now, how can it be achieved?
[1] http://blog.sptechnolab.com/2011/02/10/android/android-connecting-to-mysql-using-php/
I think a simple TCP/IP connection via Sockets will do just fine for your purposes.
The lesson (with more information and some examples) from the Java-Docs can be found here.
The basic workflow is as follows:
Your Android-App opens a Socket-connection to your server on a
given port where a server-application listens.
The Android-App sends it's data (whatever that might be) to the
Server.
The Server reads the send data,
processes it,
stores it...
...then it sends back some response (maybe the computed values) to your
Android-App.
Your app can then figure out if everything went okay and use the
given data.
Answering my second question, all the php scripts has been put into directory with the password on my Apache server. To be able to trigger them I need to give this password which is hardcoded in my application. All the connection is done through HTTPS. Now everything works as planned!
I have an Android App which uses http communication for nearly every operation. I want to be able to demo without connection to the internet by somehow replaying the http exchange. How can this be done? So I want to somehow almost like mock objects but really mock http session so I can always demo the app on or offline. This is really a very cool thing to be able to do. Since you can demo the app easily and reliably. Does anyone know how I could do this. Replicating the whole server side is just not an options its got too much stuff. Its important not to just show screencast but the real data exchange. I just want to be able to run thru the app and replay. Maybe debug as well. Thanks
Here's a hybrid solution using similar ideas from other answers:
You could write a dead simple HTTP server that listens on "localhost:80" (or whatever the port is on the server you're targeting) and point your application to this host instead by factoring out the host name from requests. Your local server has a reference to the actual remote server and does the following:
If ONLINE, forwards the request as-is to the real server, gets the response, saves it locally either in an in-memory cache keyed by the request URL or a file named with the URL as its identifier (munged appropriately)
If OFFLINE, looks up a request in its (in-memory or file system) cache and returns the contents from the cache instead
This is kind of like the record/playback mode that #nicholas.hauschild says.
Now you can just run your app once when ONLINE, causing your localhost server to save away requests that it issues against the real server. Then when you run your app OFFLINE, it just returns these cached contents instead whenever the same URLs are issued.
Hope this helps.
If you're device is rooted, you can use tcpdump as explained in this post: http://www.vbsteven.be/blog/android-debugging-inspectin-network-traffic-with-tcpdump/
or use AndroShark (get if from xda-developers here: http://forum.xda-developers.com/showthread.php?t=725692)
or this one (wifi only): http://www.9bitlabs.com/default.aspx
I would create a "Record Mode", and a "Playback Mode" for my app.
While in Record Mode, I would write out a file each time an http request was made. The file would be named by the endpoint the request is made. The contents of the file would a collection of serialized http requests/responses broken up by line. You could then deserialize lines from this file until you find the proper request, and play back the deserialized response.
This approach would also allow you to create Record/Playback profiles, where you could record multiple different sessions (by placing the files into a different directory) and then playback from whichever profile you choose.
This whole approach could be done with a small wrapper class around the HttpClient object you are using.
One way would be to use an HTTP proxy. Redirect all web traffic to the proxy, which can be running locally on the phone. This could be done with little or no source code change.
find a way using fiddler on pc,and android app take fiddler as proxy.So the http traffic is record.
http://blog.csdn.net/grhunter/article/details/5830199
Simples solution lies in faking it when there is no connection. If there is a error in connection, make sure ur app throws some preset data rather than an error in connection thing.