Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically checking for a new version of my application

Tags:

Trying to honor a feature request from our customers, I'd like that my application, when Internet is available, check on our website if a new version is available.

The problem is that I have no idea about what have to be done on the server side.

I can imagine that my application (developped in C++ using Qt) has to send a request (HTTP ?) to the server, but what is going to respond to this request ? In order to go through firewalls, I guess I'll have to use port 80 ? Is this correct ?

Or, for such a feature, do I have to ask our network admin to open a specific port number through which I'll communicate ?


@pilif : thanks for your detailed answer. There is still something which is unclear for me :

like

http://www.example.com/update?version=1.2.4

Then you can return what ever you want, probably also the download-URL of the installer of the new version.

How do I return something ? Will it be a php or asp page (I know nothing about PHP nor ASP, I have to confess) ? How can I decode the ?version=1.2.4 part in order to return something accordingly ?

like image 730
Jérôme Avatar asked Sep 11 '08 12:09

Jérôme


2 Answers

I would absolutely recommend to just do a plain HTTP request to your website. Everything else is bound to fail.

I'd make a HTTP GET request to a certain page on your site containing the version of the local application.

like

http://www.example.com/update?version=1.2.4 

Then you can return what ever you want, probably also the download-URL of the installer of the new version.

Why not just put a static file with the latest version to the server and let the client decide? Because you may want (or need) to have control over the process. Maybe 1.2 won't be compatible with the server in the future, so you want the server to force the update to 1.3, but the update from 1.2.4 to 1.2.6 could be uncritical, so you might want to present the client with an optional update.

Or you want to have a breakdown over the installed base.

Or whatever. Usually, I've learned it's best to keep as much intelligence on the server, because the server is what you have ultimate control over.

Speaking here with a bit of experience in the field, here's a small preview of what can (and will - trust me) go wrong:

  • Your Application will be prevented from making HTTP-Requests by the various Personal Firewall applications out there.
  • A considerable percentage of users won't have the needed permissions to actually get the update process going.
  • Even if your users have allowed the old version past their personal firewall, said tool will complain because the .EXE has changed and will recommend the user not to allow the new exe to connect (users usually comply with the wishes of their security tool here).
  • In managed environments, you'll be shot and hanged (not necessarily in that order) for loading executable content from the web and then actually executing it.

So to keep the damage as low as possible,

  • fail silently when you can't connect to the update server
  • before updating, make sure that you have write-permission to the install directory and warn the user if you do not, or just don't update at all.
  • Provide a way for administrators to turn the auto-update off.

It's no fun to do what you are about to do - especially when you deal with non technically inclined users as I had to numerous times.

like image 170
pilif Avatar answered Oct 20 '22 14:10

pilif


Pilif answer was good, and I have lots of experience with this too, but I'd like to add something more:

Remember that if you start yourapp.exe, then the "updater" will try to overwrite yourapp.exe with the newest version. Depending upon your operating system and programming environment (you've mentioned C++/QT, I have no experience with those), you will not be able to overwrite yourapp.exe because it will be in use.

What I have done is create a launcher. I have a MyAppLauncher.exe that uses a config file (xml, very simple) to launch the "real exe". Should a new version exist, the Launcher can update the "real exe" because it's not in use, and then relaunch the new version.

Just keep that in mind and you'll be safe.

like image 35
Martin Marconcini Avatar answered Oct 20 '22 14:10

Martin Marconcini