put url does not work in standalone Windows 10 (Solved)

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

mrcoollion
Posts: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

put url does not work in standalone Windows 10 (Solved)

Post by mrcoollion » Sat Oct 14, 2023 8:14 pm

Hello LiveCode friends,

It has been a while but now I have the following issue i do seem to be able to solve. Help would be much appreciated.

I have tried everything to get the code below working in a standalone on Windows 10 Pro.
I need the outside IP address and it works fine in development but the standalone gives no information.
In lesson 'How do I get the content of a URL on a web server into LiveCode?' I read that for https you need to include revSecurity library .
However in the 'Standalone Application Settings > inclusions' I do not see that option. I have added all available options but it still does not work in the standalone.

Hope someone else know the cause of my issue and a way to solve it ?

Code: Select all

   put empty into fld "CurrentIPAddress"
   put empty into fld "CurrentIPv6Address"
   put "https://api.ipify.org/" into tURLIPv4
   put url tURLIPv4 into tCurrentIPAddress
   put tCurrentIPAddress into fld "CurrentIPAddress" // For IP v4
   wait 1
   // For IP v6  https://api64.ipify.org
   put "https://api64.ipify.org/" into tURLIPv6
   put url tURLIPv6 into tCurrentIPv6Address
   put tCurrentIPv6Address into fld "CurrentIPv6Address"
   wait 1
Friendly greetings
Paul Agerbeek (alias Mr CoolLIon)
Last edited by mrcoollion on Fri Oct 27, 2023 10:45 am, edited 1 time in total.

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: put url does not work in standalone Windows 10

Post by stam » Sun Oct 15, 2023 2:09 am

I presume you've stepped through your code to make sure it's the 'put' that isn't working or if it's something with the code?

As for what you're trying to do, this was recently discussed in depth: https://forums.livecode.com/viewtopic.php?f=7&t=21887
If I remember correctly one issue was caching, which was stopping things from working properly for about 30-40 sec.

You can manually reset the caches, http data etc with the command resetAll
instead of using wait 1 why don't you try replacing this with resetAll and see if that works?

mrcoollion
Posts: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: put url does not work in standalone Windows 10

Post by mrcoollion » Sun Oct 15, 2023 9:51 am

Thank's Stam.

I will give it a try and come back with the results :D

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: put url does not work in standalone Windows 10

Post by SparkOut » Sun Oct 15, 2023 3:48 pm

One thing to try (which may or may not work, but is a genuinely considered suggestion) is simply to put the url (or variable containing it) into parentheses for evaluation in the statement

Code: Select all

put url (tURLIPv4) into tCurrentIPAddress

mrcoollion
Posts: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: put url does not work in standalone Windows 10

Post by mrcoollion » Sun Oct 15, 2023 9:45 pm

Thanks all for the suggestions.

Ik have tried the below shown three methods of getting the information from a site (see code examples).
All of them worked in development mode!
The only one that worked after being saved as a Standalone Application and placed on a clean user PC was the GetExternalIPTSNETGET_V01 routine that uses TSNETGET.
I still have no clue to why the others do not work after being saved as a Standalone Application and placed on a clean user PC but at least my problem is solved for now :-) .

Maybe someone can still find the reason and solution for the other two routines?

The website polled to get my external IPv4 address was : https://api.ipify.org/
The website polled to get my external IPv6 address was : https://api64.ipify.org/

Code: Select all

---------------------------------------------------------------------
command GetExternalIPPUT_V01 tURLIP @tOutIP @tResult @tMessage
   local tJSON, tArray, tCount, tMaxTries = 3
   repeat 
      resetAll
      put URL (tURLIP) into tJSON 
      if tJSON is not empty then
         put tJSON into tOutIP
         put "" into tMessage
         put "Ok" into tResult
         exit repeat
      end if
      add 1 to tCount
      if tCount > tMaxTries then exit repeat
      wait 500 milliseconds // blocking command
      put return &  "No internet connection - attempt" && tCount && "of" && tMaxTries after tMessage
      put "Error" into tResult
   end repeat
   resetAll
end GetExternalIPPUT_V01
---------------------------------------------------------------------
command GetExternalIPSHELL_V01 tURLIP @tOutIP @tResult @tMessage
   resetAll
   put "curl "&tURLIP into tCMD
   set the hideConsoleWindows to true 
   put shell (tCMD) into tShellResult
   set the hideConsoleWindows to false
   put the last line of tShellResult into tLastLineData
   put tLastLineData into tTest
   if tTest contains "curl" then
      put "" into tOutIP
      put "Error" into tResult
      set itemdelimiter to "curl"
      put "curl" & item 2 of tLastLineData into tMessage
      set itemdelimiter to comma
   else
      put tLastLineData into tOutIP
      put "Ok" into tResult
      put "" into tMessage
   end if
   resetAll
end GetExternalIPSHELL_V01
--------------------------------
command GetExternalIPTSNETGET_V01 tURLIP @tOutIP @tOutResult @tOutMessage
   put tsNetGetSync(tURLIP, tHeaders, tRecvHeaders, tResult, tBytes) into tData
   -- tResult will be 200 (the HTTP response code for a successful transfer)
   -- tsNetGetSync was able to retrieve the data
   if tResult is not 200 then
      put "" into tOutIP
      put "Error" into tOutResult
      put tResult into tOutMessage
   else 
      put tData into tOutIP
      put "Ok" into tOutResult
      put "" into tOutMessage
   end if
end GetExternalIPTSNETGET_V01
--------------------------------
Friendly greetings and thanks for all the suggestions and help.

Paul Agerbeek (alias MrCoolLion)

bobcole
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 135
Joined: Tue Feb 23, 2010 10:53 pm
Location: Saint Louis, Missouri USA

Re: put url does not work in standalone Windows 10

Post by bobcole » Mon Oct 16, 2023 5:05 pm

I experimented with the api and found a difference between http and https.

Code: Select all

on mouseUp
   put "http://api.ipify.org/" into tURL --external IP
   put URL tURL & return into message box
   
   put "https://api.ipify.org/" into tURL --internal IP
   put URL tURL after message box
end mouseUp
Worked for me in the IDE on a Mac. It is worth a try on your Windows machine.
Bob

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: put url does not work in standalone Windows 10

Post by stam » Mon Oct 16, 2023 5:19 pm

Just to confirm, your standalone includes the externals for Internet
/SSL/HTTPD?
ResetAll is part of the internet library, won’t work in standalone if not included…
Or maybe you had included and it still didn’t work?

matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 190
Joined: Sat Apr 08, 2006 7:55 am
Location: Lübbecke, Germany
Contact:

Re: put url does not work in standalone Windows 10

Post by matthiasr » Mon Oct 16, 2023 8:26 pm

I seconds STAMs post.

As http: is working it seems tsNET and Internet library was correctly select in the Standalone Settings -> Inclusions.
But you need also to include SSL&Encryption, otherwise https connections will not work.

mrcoollion
Posts: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: put url does not work in standalone Windows 10

Post by mrcoollion » Tue Oct 17, 2023 10:01 pm

Here I am again with seemingly the same type of issue :(

I keep running into problems with my application after building the standalone application.
In the development environment, all works without a problem.
All issues seem to are related to internet connections
- Now a TSNetGetSync command does not seem work in standalone although in another part of my application put tsNetGetSync... works :shock: ?!
- I tested on two different Windows 10 PC's and on both, I got the same result.
- I have set all network adapter restrictions to allow all to make sure windows in not the reason for my problems but still the same issues.
- Tested building the app in LC version 9.6.7. and still the same result (working in LC 10.0 dp5).
- I selected all inclusions with a Windows Logo and still the same result.
- I have let LiveCode select the inclusion, results were even worse (Position of SVG widget was lost on top of the known issue).

I am out of ideas on how to solve this and hope that someone has the answer as to why my standalone does not work as in the development environment.

Greetings,

Paul

mrcoollion
Posts: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: put url does not work in standalone Windows 10

Post by mrcoollion » Wed Oct 18, 2023 12:12 pm

Hi all,

After extensive testing and placing check information into a field on the card it seems that the TsNetGetSync is working fine but the problem is the ' JSONtoArray(tData) into tArray'code part. The code below does show the first put... in the designated field but does not show the second put... .
The mergJSON inclusion has been selected.

Does anyone have an idea why this does not work in the standalone but does work in the developers mode?
With Try and Catch I got the below shown error codes.

Code: Select all

      --
      put "Ok and before cmdline 'put JSONtoArray(tData) into tArray' "  into fld "PersonalNotes" // ??? for test
      ----
      put JSONtoArray(tData) into tArray //
      --
      put cr & "After JSONtoArray "  after fld "PersonalNotes" // ??? for test
      --

Regards,

Paul
Attachments
JSON_error.png
JSON_error.png (5.53 KiB) Viewed 104380 times

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9842
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: put url does not work in standalone Windows 10

Post by FourthWorld » Wed Oct 18, 2023 5:32 pm

That error reporting dialog is itself an error. If you were wondering why it's nearly completely useless, that's because it's debug info for the IDE or widget author, not meant to be seen by end-users.

Do you have a simple recipe for displaying that error dialog? I'd sure love to pin that down and get it resolved once and for all. It's been showing up for years, but each time I've asked for a recipe I've not rec'd one.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

mrcoollion
Posts: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: put url does not work in standalone Windows 10

Post by mrcoollion » Wed Oct 18, 2023 7:15 pm

To help you as much as I can I made a small application to simulate the problem.
It uses the actual data I receive from coinmarketcap (Yes I am making a support application for crypto traders)
In development mode, there are no errors.
After making the executable there are errors.

Hope you see the same results.
I use Windows 11 Home for development
I run the application also on 'Windows 11 Home' and on 'Windows 10 Pro'. Both give the same results (error).

The executable is 167 MB because i selected all inclusions to make sure it represents my LC builder environment. It is therefore to big to share here.
If you need it let me know.
I really appreciate your help.... :D

Kind regards,

Paul
Attachments
LCBugTestJaysoToArray_V01.zip
(25.41 KiB) Downloaded 51 times

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: put url does not work in standalone Windows 10

Post by stam » Wed Oct 18, 2023 8:28 pm

Well that was a bewildering test... your final app must be a behemoth.

Apart from the myriad of externals included, it also generated these errors on build:

Code: Select all

1	Icon does not exist:C:/Program Files/RunRev/LiveCode 10.0 (dp 5)/Runtime/Windows/x86-32/Support/Sample Icons/genericapp.ico
2	Icon does not exist:C:/Program Files/RunRev/LiveCode 10.0 (dp 5)/Runtime/Windows/x86-32/Support/Sample Icons/genericdoc.ico
3	Extension community.livecode.hermann.digitclock not found
4	Extension community.livecode.berndn.gauge not found
5	Extension community.livecode.hermann.clockAround not found
6	Extension community.livecode.hermann.textbanner not found
7	Extension community.livecode.hermann.icongrid not found
8	Extension community.livecode.hermann.bezierclock not found
9	Extension community.livecode.hermann.hhsvgtext not found
I built standalone for MacOS - it seems to work just fine. Or at least the same as in the IDE. There are just buttons, nothing else is interactive. The "Convert JasonToArray" [sic] button just generates the phrase "Successfully converted to array" and the "Clear fields" buttons clears the message.

No difference between standalone and IDE on MacOS at least!

S.

mrcoollion
Posts: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: put url does not work in standalone Windows 10

Post by mrcoollion » Wed Oct 18, 2023 8:49 pm

Hello S,

It is true that the final app is pretty extensive and it all works in developers mode...
Maybe it is a Windows-related issue?
the extensions are extensions I have in my developer tools menu.
I do not get any errors I know of while generating the standalone application.
Below is the result of running the bugtest application and as you can see it generates an error capture in the lowest field.
The left version is the version running in Developer mode, the right application is the build executable that shows the error.

Are you *(or anyone else) able to compile and test it in Windows?

I have no clue as to what to do now.
Any suggestions?

Paul
Attachments
NVIDIA_Share_OdnMyq0AtQ.png

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: put url does not work in standalone Windows 10

Post by bn » Thu Oct 19, 2023 11:34 am

Hi Paul,

Disclaimer: I do not have a Windows Computer and so I am guessing.

I noticed that you had chosen a lot of inclusions for testing "JSONToArray". For the sake of reducing possible errors I would uncheck all except mergJSON. Furthermore I would not choose as target build both "Windows x86" and "Windows x86-64". I would do a test using either in standalone building. The rationale is that it is possible that mergJSON might not be compiled for "Windows x86-64".

Do you test on real Windows hardware or in emulation? If e.g. you use Parallels you have to configure it to work with "Windows x86-64".

Since it is mergJSON that is failing you might consider alternatives like

https://github.com/bhall2001/fastjson/b ... astjson.lc by Bob Hall

https://github.com/Ferruslogic/PhotonJSON and use it as Library

Or "JSON Library" that comes with LC. (Search the dictionary for JSON)

Maybe experimenting with this will help to find a solution. But you have to test extensively because each JSON library handles the conversion a bit differently.

Kind regards
Bernd

Post Reply

Return to “Talking LiveCode”