HTTPSocket.Get Trouble

For an updater, I want to download new versions of my app with a httpSocket. Therefore I have dragged a httpSocket onto my update window. A button calls:

f=SpecialFolder.UserHome.Child("Downloads").Child("Goldfish_4-0_Macintosh.dmg") If f<>Nil Then DownloadSocket.Get "http://www.fishbeam.com/software/Goldfish_4-0_Macintosh.dmg", f End If

With click on the button, a file named “Goldfish_4-0_Macintosh.dmg” is created in downloads. But no download begins. The file remains empty and no event from the httpSocket is called. No Connected, no Error, no ReceiveProgress, no DownloadComplete. Did I do something wrong? I just want to download the file “http://www.fishbeam.com/software/Goldfish_4-0_Macintosh.dmg” to the “Downloads”-folder.

You can check a demo project here. It contains only a button that starts the download. And the code “Beep” with a Breakpoint in all available httpSocket events to check if they get called.
http://www.work.fishbeam.com/XojoDownloadBug.zip

I removed the double post

Have you looked at the Kaju updater framework that Kem posted ?
https://forum.xojo.com/18773-xojo-based-self-updater-classes-from-kem-tekinay/0#p157312

Look here : https://github.com/ktekinay/Kaju.git

Thank you. :slight_smile: The kaju updater framework is nice but I can’t use it without much modifications. And it does not explain why

DownloadSocket.Get "http://www.fishbeam.com/software/Goldfish_4-0_Macintosh.dmg", f

does not work. I use this code in all my Windows and Mac Carbon apps for years but it seems to be broken under Cocoa.

Patience seems to be required
Here it runs and I eventually got an error event with error code 22
I’m not sure why

It seems to be on a flaky server.

  1. On one attempt at a restart it gave me a 416 Requested Range not satisfiable, though it was and restarted again correctly several times.
  2. The connection keeps being dropped by the server, like badly. I canned it at about 20MB after 5 restarts.

Then, I finally got the file it was the wrong size.

Tried again, no drops, file correct size.

I’ve had sporadic results as well

Hmm, then you get better results than me. I never get any bytes downloaded and sometimes error 22 appears. Some web searching revealed:

Error 22 is “Invalid argument”. http://www.monkeybreadsoftware.eu/listarchive-realbasic-nug/2011-08-09-5.shtml

I am not sure if the problem is on the web server. the code

ShowUrl "http://www.fishbeam.com/software/Goldfish_4-0_Macintosh.dmg"

works always here and Safari downloads the file without trouble.

I tried the URL in Safari and got the file once and and error on another try

Came down OK on Firefox on PC.

I have found the problem.

My updater did not work because I used

UpdateWindow.ShowModal

to show the window on that the download socket is located. It seems that the code execution stop from .ShowModal prevents all events of httpSocket from being fired unless you call .Hide or .Close. Is this a Cocoa bug? I have altered my code so that I don’t need .ShowModal for that window anymore.

My demo project did not use .ShowModal for the window so that you could not reproduce this.