Sending verification request every single second to the server (repeating task) - iphone

I've some service that's being called by a Mobile app.
The mobile app need to be up to date with the server.
So, Every 1 second I do check the server for any additional data, if found I got the data from the server (repeating task).
Is there any problem from sending an HTTP request every single second (most of the time the response is very small, just to tell the client no data found)?
I am using Oracle App server for Server and iPhone for Client.
Thanks.

It will probably eat your client's battery, and create a lot of load on your server.
You can try commet long polling approach or the newer (and not well supported yet) WebSockets instead.

Related

Delphi rest client/server (webbroker) + database +simultaneous client requests

I'm new to REST developing and i'm creating a simple rest API to request database values from clients. I have used the "Delphi Web Server Application" project assistant (the one that uses TIdHTTPWebBrokerBridge and the WebModule where you create the different 'Actions'). It works fine and I can make requests from client(s).
The server WebModule contains a FDConnection and some FDQuery components to make the database (MySQL) queries, and each Action executes a specific query with specific params obtained throug request params.
The client app uses TRESTResponse, TRESTRequest, TRESRResponse components to send/receive the data.
For example:
client request to server some values for a specific user, sending "user = user1" and "passwd = ***" as request params.
server executes the query "select * from xxx where user = user1 and passwd = ...…..." and sends the response to the client.
Every query is "user-specific".
Ok, it works, but now I have some misgivings due to my rest/webbroker functioning ignorance.
What if thousands of requests are made at a time? Could the server respond incorrect data because the FDQuery cursor is in another record?
Or does the webbroker create the query for each request with no problem?
Is it better to create the FDQuery at runtime for each request and destroy it after request completion?
I made a simple test yesterday, running three instances of the Client application and sending 300 requests to the server (100 from each client) simultaneously and it worked, receiving correct data, but I don't know if this is enough guarantee.
Is this (Delphi Web Server Application) the correct method to créate the server? What are the differences with DataSnap?
Any advice?
In the Datasnap architecture (there are several flavours, but they all have a common architecture), the "server" makes 1 copy of the ServerMethodsUnit for each client connection. This is with the ServerClass.LifeCycle set to Session. Therefore, each client will be able to execute a servermethod and have the result returned to it, independently of what any other client may be requesting.
In your case, each ServerMethodsUnit will have it's own FdConnection, FdQuery and so on, wether you place design-time components there or instantiate them at runtime, the consequences are the same.
The limit here will be the hardware that the Datasnap/WebBroker application is running on. (Network bandwidth, RAM, Hard drive speed etc)
Datasnap (REST, DBX, Standalone, ISAPI, Apache, Linux), in my opinion is a sound basis for client/server development.

How to send data to multiple client sockets

I have an AIR server application. Several mobile clients connect to it. Everything works good, if there is only one client, but when the server sends data to several clients in a loop, the clients fail to process the data immediately. The data is late by one step.
This bit of code is inside a for loop:
clients[i].client.writeObject(data);
clients[i].client.flush();
Only the client sending the data is getting the update from the server. Everyone else is quiet for one step. If the client sends another message, then all other clients are updated to the state of previously sent update.
The code is fine on clients, as the client running on a computer is receiving the updates on time. Only the mobile clients are failing to update.
What could be the reason for this issue?
What is the proper way of sending data to multiple client sockets at the same time?
I have solved the issue by setting a timer to delay the data transfer by 1/3 of a second. Less delay time caused the same issue. I do not think it is the only solution, but it worked.
The problem with this solution is, if the there are 100 clients, the last will receive the data updates in 30 seconds.

IIS Streaming/Pushing JSON to iOS

Quick Version:
I want to send timely data updates (in JSON) from an IIS WCF RESTfull webservice to an iOS custom-application. I don't want to poll due to bandwidth costs and the update-rate I need to achieve. My clients communicate to their server over the internet.
I'm confused by my options, and most of the information I read is out of date, targeted for web-browsers, or for media streaming.
Is there a current best-practice / standard-practice I should be using?
Extra Details:
I have approx 25-100 iOS (v5.1) clients (iPads).
I 'd like my clients to see an update within about 5 seconds of an event occurring.
My clients are running 24x7, and communicate over a 3G network.
The application only needs to receive the data while it is running (no requirement to show a notification when the app is minimized).
Using a 3rd party service, or having to set-up a special server on my end is a no-go.
Whatever I do needs to integrate nicely with my existing IIS WCF webservice.
No additional research is required because you've asked a perfectly constrained question:
There are only two choices: push or pull, and pull is ruled out.
There is only one way to push: APNS.
Without third party assistance, there's only one option: build an APNs provider.

Sync the sqlite data of iphone application to server

I am trying to make the sync data application in which user have some value into the data base .And he have to send this data on to the server .With help http request how can i do that .
I need the
I am not using the php web server .
I am using the Normal HTTP web page .
ANd i have the some data in my iphone application and i want to Synchronization that data to server .
I it must check the Internet is available or not .If the Internet is ON than only he will Synchronization the data .that's my question .
Nothing else .You got my point or not .
I thing people will reply me soon please
Thanks
You have got to have some kind of server backend for synchronization of the local database. You can't do that using just the static HTML pages.
Your application and server have to have a way to talk to each other using a web service protocol, like SOAP or JSON/REST. Then your application has to translate the data from the database into such web service data objects.
Both your local database and the server (in case of more than one client) will have keep the records of at least the times of last synchronizations so both know what should be sent over the air in order to become in sync.
Also, in the usual case of more than one client, you have to solve the problem of conflicts resolution.
Web service versioning is important as well, as there will be very likely a need to improve the communication channel, maybe there will be changes in the database model to be synchronized.
As you can see, the idea of synchronizing local database to a server is not that simple, and if you think you can do it in a simple way, in time you'll realise that you're gradually reimplementing the aforementioned ideas.
Do a research on web service technologies, writing web services-aware apps, on synchronization with web services and on Reachability, for starters.
To check internet availability, check out the Reachability class from Apple. See this article.
To send data to a simple HTTP form via POST use NSURLConnection like in this article.
Cheers,
S

How do they make real time data live on a web page?

How do they do this? I would like to have web pages with data fields that change in real time as a person views the web page. Here is an example.
How do they do this? JQuery? PHP?
I need to connect my field data to mySQL database.
There are two approaches:
Polling
Client requests data on a regular basis. Uses network and server resources even when there is no data. Data is not quite 'live'. Extremely easy to implement, but not scalable.
Push
Server sends data to the client, so client can simply wait for it to arrive instead of checking regularly.
This can be achieved with a socket connection (since you are talking about web pages, this doesn't really apply unless you are using Flash, since support for sockets in the browser in the browser is currently immature) - or by using the technique known as 'comet'.
Neither socket connections nor comet are particularly scalable if the server end is implemented naively.
- To do live data on a large scale (without buying a boat load of hardware) you will need server software that does not use a thread for each client.
I did it with JavaScript timer set execution in milliseconds, each time timer executed function that queried Server with Ajax and returned value(possibly JSON format), then you you update your field with the value. I did it each 5 sec and it works perfectly. In ASP.NET I think it called Ajax Timer Control.
There are two things needed to do this:
Code that runs on the browser to fetch the latest data. This could be Javascript or something running in a plugin such as Silverlight or Flash. This will need to periodically request updated content from the server.
Which leads to a need for...
Code that runs on the server to retrieve and return the latest data (from the database). This could be created with any server sided scripting language.