2017년 4월 26일 수요일

Web component screen.ErrorOccured NOT trigerred when using DIRECT IP over mobile


How to replicated the problem:

1. Set your phone to work on mobile data, not wifi.
2. Create a Web component.
3. use When screen1.ErrorOccured to catch worng URL responces (error 1101)
4. Set URL to a specific address (e.g. 192.168.2.15) that does not exist, not text.
5. call Web.Get.
6. Event  screen1.ErrorOccured is not triggerred!
7. Disable data on the phone. Event ErrorOccured is then immediately triggerred!
8. Repeat from step 1 on Wifi. ErrorOccured is triggered.
9. Change URL to "ljfdh.dfsdg.sdgfsd" (does not exist). ErrorOccured is triggered
Any idea why and how resolve?

--
Please prepare an example as small as possible, which demonstrates this issue and add the project (aia file) into this thread, so someone can take a look

--
Please see aia file.

I simply took http://www.imagnity.com/wp-content/uploads/2013/03/CheckConnection.aia 
CheckConnection.aia as example and replaced "www.google.com" with 192.168.1.15.


PLEASE MAKE SURE TO TRY IT USING MOBILE DATA AND NOT WIFI. Over Wifi it is ok.


--
Excellent example!

Guess the following might be the cause:

When you are using Mobile Data, and access 192.x.x.x, you are attempting to connect to a local network on your ISP's network. This is usually blocked by ISPs and you'll get a connection timed out error when you try to access it over any browser.

When you are using WiFi network, this refers to another network (intranetwork) on the Same PC Network, the router refuses the connection, and hence this triggers the error 1101.

Changing the IP address to 127.x.x.x does trigger the error block, and therefore I think the above explains this. This also explains why, when you disconnect the mobile data, the error block is triggered. The web component is waiting for a response (indefinitely) and when the mobile data is turned off, this error occurs, and triggers the 1101 error block.

Just a tip: in your example: You've used Label4 and Label5 so as to center the check button. This can also be done by setting the HorizontalArrangement1's elements to be centered by AlignHorizontal Property to Center.

--
Thank you for the explanation!
I would have expected Web component to have timeout like the browser does...Even a configurable timeout would have been preferred.

Anyway, what I am trying to do is access a local device. I want the app to check if I am on the same subnet of the device. If yes, access it via intranet. If not, via Internet (and port forwarding). Any idea how can I do this switch-over automatically?

--
I would have expected Web component to have timeout like the browser does...Even a configurable timeout would have been preferred.
The web component doesn't have this funtionality, unfortunately.

I want the app to check if I am on the same subnet of the device
If you can use extensions, you can use the WiFi Manger Extension to get the Local IP of the device in the conneacted network. May be this can be used to determine?
The extension is available here:
http://puravidaapps.com/wifi.php
com.puravidaapps.TaifunWiFi.aix
wifi.aia


The App Inventor Extensions are currently in testing. See the announcement for more information and read the App Inventor Extensions Document about how to use an App Inventor Extension.
You have to use the extension test server together with the corresponding companion app. You can download the companion app from the Help menu -> Companion information. This doesn't have the android permission to change_wifi_state (WiFi permission) and you'll get an error. However, the compiled app should work fine.


If yes, access it via intranet. If not, via Internet (and port forwarding). Any idea how can I do this switch-over automatically?
I'm sorry, I don't have experience with them, and so I cannot help you. If the device has a server set up and responding at that IP, the web component can be used...

--
Thank you.
Will look at the proposed extension.

I hope timer will be added to Web component..... 

--

HTTPS support on WEB component


I use App Inventor for my personal use and as training tool on Makers and Internet of Things courses.
In particular, I frequently use Web component, which is fine for training purposes, but not so much for my personal use.
In fact, my typical application is to build an APP sending HTTP requests to a web server running on Arduino Yun or Raspberry located in my home. The purpose is to remotely command or check some devices while I'm out of the house.
Obviously using HTTP protocol I have several doubts about the security of my APP.
Is it planned a new component like Web component able to send HTTPS requests?
Of course I could write an extension from Web component... but before starting this not trivial job I want to be sure that official support for HTTPS on App Inventor is not under development.

--
the web component also can send https

for example see my OAuth examples here https://puravidaapps.com/tutorials.php#oauth or the Dropbox example https://puravidaapps.com/dropbox.php

--
Probably my problem is caused by the fact that Arduino Yun has a self-signed certificate.
On Web component of App Inventor I receive an "Error 1101: Unable to get a response with the specified URL: https://<yun ip address>/<resource>".
But if I use WebViewer component with IgnoreSslErrors flag to true, I have no problem on display the same https url
Any idea on how to accept self-signed certificate on Web component?

--
I have assigned this as issue #791. We will look into providing a property for the Web component to have it ignore ssl errors (presuming that is the problem here, we need to investigate a bit more).

--
Do we know what IoT  clients/services do about this?

--

search for Error 1101 with WEB component


Probably my problem is caused by the fact that Arduino Yun has a self-signed certificate. On Web component of App Inventor I receive an "Error 1101: ...
The web component is waiting for a response (indefinitely) and when the mobile data is turned off, this error occurs, and triggers the 1101 error block.
use the Screen.ErrorOccurred event to catch that error, see also. How to check Internet connection by Saj. Taifun.
I have found and fixed this bug. It should be in tomorrow's release. The problem was caused by our updating minSdk from 3 to 4. The Web component ...
Step-2: From under the "Connectivity" menu in the palette, click and drag the " web" component into the viewer. Step-3: ... You have to be connected to the internet when the screen is opened, else you'll get a "1101" Error message.
yes, I also get error 1101. probably they have some kind of protection running to avoid people downloading their lyrics? Taifun.
I've narrowed it down somewhat. When I manually type in the same address and send it through the web component it will go through. It is when I use ...
error 1101 normally means, there is no internet connection, you did not get any response at all from that URL. The Web Component doesn't have an ...
ERROR 1101: Unable to get a response with the supplied URL ... After a lot of testing this ... IMHO there should be a "IgnoreSslErrors" option like in the WEBVIEW component, so it can overcome this 'feature' and work has expected.
I am trying to use a local mysql database to store and retrieve data but when I want to connect I get this: error 1101 unable to get a response with the ...


Dates in app inventor


Hi friends, I have a problem, and I can´t solve it
I have two dates, one from the datepicker and one from the current date, what I want to do is to have the diferences in days from one date to other.
I made the blocks and it work, but for some dates i goes wrong, for eg. today is 6/3/2017 and pick the date 11/03/2017 and it work.. but if I pick 15/3/2017 I have worng answer...356 days!!!.
What do you think that I am doing wrong?


--
see the documentation and define fecha_fut accordingly
http://ai2.appinventor.mit.edu/reference/components/sensors.html#Clock


InstantInTime MakeInstant(text from)
Returns an instant specified by MM/DD/YYYY hh:mm:ss or MM/DD/YYYY or hh:mm. An example text input is "06/22/2015 12:18"


also you could simplify a little bit, see screenshot...
and: use Do it to debug your blocks, see tip 4 here
Top 5 Tips: How to learn App Inventor

-- 
Thanks Taifun for your help, I don´t undestand where is the problem.... I define the variable as dd/MM/YYYY


Also, I simplify as you recommend : 

But still not workin ..

-- 
if you take a look at the documentation, you will realize, that the MakeInstant method needs the format MM/DD/YYYY  and NOT DD/MM/YYYY

InstantInTime MakeInstant(text from)
Returns an instant specified by MM/DD/YYYY hh:mm:ss or MM/DD/YYYY or hh:mm. An example text input is "06/22/2015 12:18"

-- 
15/3/2017 is the third of Marchtember,  the 15th month of 2017.

-- 
WOW!!! TAIFUN you are the best!!! many thanks.....

-- 
Even if it is working now,  you will not get the right number of days for every dates. eg. 09/15/2016 - 01/01/2004 = 4641   - you'll get 4640.

-- 
Alternatively, you could use DateUtils extension that uses much less blocks, auto-calculates leap years and, to my opinion, simpler to use.

-- 
I loaded your days.aia file and I get 4640. maybe this (android) bug is only in the european (german) date format.
I found, that I get correct results by adding 12h.


here is a screenshot from a test app  which shows the wrong dates 

--
Thanks a lot for the help!!. You are awesome!

--
@Rudolf: if you calculate the duration in hours, whats the difference then? 1 hour? probably it's a daylight saving time issue then?
which Android version are you using?

--
Maybe it's an International Date Line problem, like 
in Around the World in 80 Days?

What's the time zone and date setting in the device or emulator?

--
yes it is 1 hour diff.


using
Samsung S2 -  Android 4.12
Tablet - Android 4.03
Tablet - Android 4.42

time zone:

just testing dates between DST 0 +1h     (give me 20 min)

--
ok
what happens, if you try to get the duration between 01/01/2004 and 01/11/2016 (i.e. a date outside of the daylight saving time)?

--
you are right

it is the DST  

DST starts in Germany at march , 26   2.00am -> 3.00am

and then starts the 1h difference.

and ends October, 29   3.00am -> 2.00am

and i got the day back

So everything works, if you add 1h (i did 12h) to the date difference (in ms) . That is how I solved the problem.  And now I learned why ;-)

-- 

AI2 Client PRO check-in/check-point...


After a long, arduous and perilous journey into the unknown...
I just want every one to know...
I still have a little bit further to go... but...
I can see home already!
word!
Here is the final 'look and feel' for this year's edition of AI2 Client PRO!

<]8^) ~ Dunce Cap Software


--
well... next stop youtube! (anything but code for at least 1 hour!)

--