I was asked this question durning an interview: How to send large data to a phone?
I've heard words like "long pulling" or "streaming" but I don't know how to do it. Finally I said you can split the data to smaller chunks and send it over HTTP. The interviewer said "Well that was interesting...". I guess that was not a good sign.:(
Anyway, what is the best practice for sending large data file to a mobile device?
I've used the following approach in recent project:
Mobile device requests data from server via web service and starts to send requests with time interval to check if server is ready with data
Server prepares large response, packs it to ZIP file (compression is pretty good for text files with raw data - 5MB goes to 100Kb) and places this file to a specified folder
Mobile device gets a response from server that data is ready. This response contains a link to file.
Mobile device downloads the file, unpacks it - you got your data on mobile!
The same approach is used to send data from mobile to server.
Related
Is there away for server (web-server of web-page or file server) to know what bandwidth client had during last access or during page/file request? Can this information be sent via cookie or together with page/file request?
I guess this is more of theoretical question, since I want to know if server can provide lower resolution image for clients with bad bandwidth available to them.
Yes; use JavaScript Image onload event to time the download speed of a small image (like a logo), then do something usefull with the result like downloaded a large image if the client has the bandwidth.
Well...
I am working with an mobile application and a web server.
A characteristic of my web server is that it generates different set of data randomly. In other words, I cannot predict when the server will have ready data to send to the mobile app.
On other hand, the mobile app need to receive all data that the server generates. An approach could be request multiple times to get all these data. Indeed, It isn't a good approach, because I don't know when request the data.
If the mobile app could listen the server, after one start request or keep on the connection, for example, the server could sent any set of data in any time.
The question is: What is protocol suitable to this situation? How could I use that? Examples?
Thank you!
You could create a persistent TCP/IP connection to the server and permanently listen for incoming data (using a custom protocol or propably something websocket based). However such a permanent connection might seriously affect your battery life if it's for a mobile device. You will also lose the connection if the operating system automatically shuts down your application because it's out of memory.
The default approach to this problem are Push notification / Push services, where your server sends a notification about new data to a server of the phone provider (e.g. Microsoft or Apple push server), and this server sends the notification (as well as notificaiton from other online services) to your phone.
Some info for Windows Phone:
http://msdn.microsoft.com/en-us/library/hh221549.aspx
http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff402558%28v=vs.105%29.aspx
Depending on how often you have new data both approaches can make sense.
WebSockets could be the answer: http://en.wikipedia.org/wiki/WebSocket
Specifically, for Windows Phone, there's a solution also: http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff402558(v=vs.105).aspx
I have been developing server side applications in java, and now I have been asked to serve some mobile applications. The question always bugs me over "how much" data should I send to the app ?
If I have to transfer a large xml document, should I send it node by node, as per requirement....if yes, wont it consume the phone battery more (as the phone will be creating new connections for all the nodes). If I decide to send the whole document at once, it may take a long time for the client to download the whole doc, and may have problem temporarily storing it...even more, there may arise data inconsistency in the two copies of data. In short, I need to know "is the creation of connection for a mobile device, too expensive ?" Which approach is better - receive data in chunks, by creating multiple connections OR receive all data together in one connection.
I also need to know, while developing my web service for the mobile clients, should I send them the image URI or the image data (as byte array) ?
Thanks.
You should download as few (times) as possible.
It´s the application that will answer your question. Don´t download lists of 1000 items, load just 10, wait the user scroll down, load next 10. cache the items.
A bit more tricky way to do soemthing like that is registering the user, that is downloading data, on the begining, he first time uses the app, it will download as many stuff as you need, call it the first time loading. Register, what the user downloaded. The next call from the user u send him only data that was changed, and send with this data the changeactions to perform on the clients device.
With mobile clients, the latency kills more than the data package size. While you should not send more data than you are going to consume, node by node is not a good method to employ. This is not as much a battery answer as a user experience answer.
The best way to architect for mobile is find the right bite size for the meal. In other words, you don't send 10,000 records at one time, but you don't send a grid of 10 items 1 row at a time.
Depending on image size, you should send the image directly (base64 encoding is common) and not as a link. An exception would be sending the user to a web page and letting them browse, but then it is not really a "mobile application" any more, right?
I am writing an application, similar to Seti#Home, that allows users to run processing on their home machine, and then upload the result to the central server.
However, the final result is maybe a 10K binary file. (Processing to achieve this output is several hours.)
What is the simplest reliable automatic method to upload this file to the central server? What do I need to do server-side to prevent blocking? Perhaps having the client send mail is simple and reliable? NB the client program is currently written in Python, if that matters.
Email is not a good solution; you will run into potential ISP blocking and other anti-spam mechanisms.
The easiest way is over HTTP via a simple webservice. Have a listener at your server that accepts the uploaded files as part of a HTTP POST and then dump them wherever they need to be post-processed.
Ok so coming in from a completely different field of software development, I have a problem that's a little out of my experience. I'll state it as plainly as possible without giving out confidential details:
I want to make a server that "does stuff" when requested by a client on the same network. The client will most likely be a back-end to a content management system.
The request consists of some parameters, an input file and several output files.
The files are quite large, from 10MB - 100MB of data that must be processed (possibly more). The client can specify destination for output files.
The client needs to be able to find out the status of the request - eg position in queue, percent complete. And obviously when and where to pick up output.
So, my questions are - What is a good method for the client and server to communicate? Should the client poll the server, or provide a "callback" somehow for status updates?
At this point the implementation platform is completely open - anything from C to scripting languages like Ruby are available (at either end), my main issue is how the communication should occur.
First thought, set up some webservices between the machines. But webservices aren't going to be too friendly or efficient with the large files.
Simple appoach:
ServerA hits a web method on ServerB "BeginProcess". The response give you back a FTP location username/password, and ticket number.
ServerA delivers the files to FTP location.
ServerA regularly polls a webmethod "GetProcessStatus(ticketNumber)", possible return values: Awaiting files, Percent complete, Finished
Slightly more complicated approach, without the polling.
ServerA hits a web method on ServerB "BeginProcess(postUrl)", and you send along a URL you want status updates POSTed to. Response: FTP location username/password, and ticket number.
ServerA delivers the files to FTP location.
ServerB sends thru updates to the POST location on ServerA every XXX% completed.
For extra resilience you would keep the GetProcessStatus in case something gets lost in the ether...
Files that will be up to 100MB aren't a good choice for a webservice, since you run a risk of the HTTP session timing out before you have completed your processing.
Having a webservice for checking the status of these jobs would be more ideal. Handle the file transfers via FTP or whatever file transfer method you choose and poll a webservice for updates on status. When the process is completed, you might have an output file url returned that can be downloaded.