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..... 

--

댓글 없음:

댓글 쓰기