I’m not sure what that’s about as Kaju doesn’t cache that file. Have you tried tracing through the code to see what url it’s actually loading?
Thank you Kem for looking into it. I was doing more tests and found this:
When using Checker.ExecuteAsync, I have this problem, changing to Checker.Execute() solve the problem.
I have 2 test files on the server, UpdateInfo.html and UpdateInformation.html both with 2 versions, UpdateInfo.html101 (is with a new version 1.0.1 file) and UpdateInfo.html102 (version 1.0.2), just to make sure changing files back will change the information shown.
One button use Checker.Execute() and check UpdateInfo.html the other use Checker.ExecuteAsync and check UpdateInformation.html
I change from 101 to 102 and Checker.Execute() will show 101 or 102 as I change the files. Checker.ExecuteAsync always show the same information.
My URL is in like this: https://user:pass@server.com/kajutest_auth/
Kem, I used your demo to test this.
- have UpdateInformation.html101 and UpdateInformation.html102
- rename UpdateInformation.html101 to UpdateInformation.html
- change the ‘Asynchronous’ check mark to use both options
- both shown the 1.0.1 information
- rename UpdateInformation.html102 to UpdateInformation.html
- without the ‘Asynchronous’ check I get 1.0.2 information
- using Asynchronous, still get 1.0.1 information
screengrab:
Edit: I changed the URL information to not make public my actual server, username and password
I have to believe this is server-side. Can you turn off caching in that directory?
Or can I set “no-cache” in the header of the requests to avoid caching?
I think that’s a very good idea for the way this gets used
Will the server honor it though?
I’ll try to do that, but my question here will:
if this is a cache issue and only affect the Asynchronous code, isn’t there something on Xojo’s side that will force the check?
And other question:
if cache is the issue, why all browsers behave correctly? As soon as I replace the 1.0.1 with 1.0.2 or back and reload the page, I get the correct information.
Once we get to the bottom of why it’s happening, the answers to these questions might present themselves.
With @Alberto De Poo 's help, it’s now resolved, and adding the request headers did it. The fix is now in the develop branch.
HHTPSocketAsync.SetSecure now reads this way:
Private Sub SetSecure(ByRef url As String)
ValidateCertificates = true
Username = ""
Password = ""
ClearRequestHeaders
RequestHeader( "Cache-Control" ) = "private, no-cache, max-age=0"
RequestHeader( "Pragma" ) = "no-cache"
url = url.ConvertEncoding( Encodings.UTF8 )
#if not TargetMacOS then
//
// See if the username and password has been specified
//
dim rx as new RegEx
rx.SearchPattern = "^(https?://)([^:/\\x20@]+):([^:/\\x20@]*)@(.*)"
dim match as RegExMatch = rx.Search( url )
if match isa RegExMatch then
Username = DecodeURLComponent( match.SubExpressionString( 2 ) ).DefineEncoding( Encodings.UTF8 )
Password = DecodeURLComponent( match.SubExpressionString( 3 ) ).DefineEncoding( Encodings.UTF8 )
url = match.SubExpressionString( 1 ) + match.SubExpressionString( 4 )
url = url.DefineEncoding( Encodings.UTF8 )
//
// Set the request header manually
//
dim encoded as string = EncodeBase64( Username + ":" + Password ).DefineEncoding( Encodings.UTF8 )
RequestHeader( "Authorization" ) = "Basic " + encoded.ToText
end if
#endif
End Sub
I added the second “Pragma” just in case, but the first “Cache-Control” by itself did the trick. As HTTP is not my forte, any other suggestions?
I just added a public key override to the test app. You can now use it to test your own update files without having to change code.
This is still in the develop branch.
I’ve added two features, one of which I’d like feedback.
The first is a security token added to the export. This is a random 8-byte token, Base64-encoded, that will be added to each version’s info. This will ensure that each export of the information will have a different RSA signature and will not affect older versions of Kaju as it just ignores that field anyway.
The second, the one that requires feedback, is compensation for different line endings. My concern is for those that open the export packet and end up saving it with different EOL characters. With that in mind, Kaju will try to validate the raw JSON string as-is and with the line endings replaced with each of the three possibilities until it finds it valid. The code looks like this:
dim isValid as boolean
dim eolChars() as string = array( "", &u0A, &u0D, &u0D + &u0A )
for each eol as string in eolChars
dim tester as string = raw
if eol <> "" then
tester = ReplaceLineEndings( tester, eol )
end if
isValid = Crypto.RSAVerifySignature( tester, sig, ServerPublicRSAKey )
if isValid then
exit for eol
end if
next
if not isValid then
return HandleError( KajuLocale.kErrorIncorrectPacketSignature )
end if
Good idea? Bad idea?
A bit off here, but any reason why I would get the “This OS is not supported (missing required tools) message?” randomly?
I had this working fine last week, with no issues at all… now, I get this message quite often… not all the time, but it is enough to tell me Ive messed something up somewhere.
If I go into the OSisSupported and delete this:
[code]#elseif TargetWindows then
dim sh as new Shell
sh.Execute “XCOPY /?”
r = sh.ErrorCode = 0
#else // Linux
dim cmds() as string = array( “rsync --version”, “/usr/bin/logger --version” )
dim sh as new shell
for each cmd as string in cmds
sh.Execute cmd
if sh.ErrorCode <> 0 then
r = false
exit
end if
next[/code]
Then everything works great again.
This is on a window machine, building for windows only
Deleting that code is not the answer because, if XCOPY is truly missing, the whole process will fail without warning. Instead, log the error code and result so we can get to the bottom of it.
My guess is that it’s a timing issue. I’ll add a timeout, some logging, and perhaps a loop so it can try more than once.
I mean, removing code from the function OSisSupported
seems like such a good idea.
Be nice, Tim.
@kyle hamer I’ve pushed those changes out to the develop branch, please let me know what you find.
Thanks, that worked.
One last issue, how do I go about debugging the update?
I can successfully download the file and when I go to install it, I end up with an error saying the “MyApp.exe” cannot be found. Even tho that was the file I used to originally get the update with.
The log file is littered with stuff like:
“…not found as file, trying as directory”
“…NOT FOUND!”
etc
The MyApp.exe WAS there, but it gets deleted once the updater begins to work. All the names are the same. I did compile v1 and places the files on the desktop.
MyApp (folder)
- MyApp Libs
- MyApp Resources
- MyApp.exe
The v2 directory structure is the same, including names.
Any Idea?
Post the whole log please.