There was a bug that was causing setProperty() settings to be ignored.  I
have fixed it in Git.
https://github.com/codenameone/CodenameOne/commit/10e981d67ee60c84825c6c8bfd068cba872d7eb6

Should be available in the update tomorrow.

A workaround would be to use a local web server to serve the file and
connect to it using http://localhost/... rather than using the jar://
(file://) protocol as this won't be subject to the same security
constraints.  You can create a local web server using this module:
https://github.com/shannah/CN1Webserver

Steve



On Thu, Apr 5, 2018 at 10:04 AM, Thomas <[email protected]> wrote:

> Unfortunately this isn't working. I still have the same error message.
>
> I put my test code on github so you guys can have look if you want:
> https://github.com/ramsestom/CN1SocketIO_test
>
>
> On Thursday, April 5, 2018 at 1:25:47 PM UTC+2, Steve Hannah wrote:
>>
>> Try calling
>>
>> myBrowserComponent.setProperty("AllowUniversalAccessFromFileURLs",
>> Boolean.TRUE);
>>
>> (on the BrowserComponent)
>>
>> Before loading the page.
>> Ref: https://stackoverflow.com/a/13740831/2935174
>>
>>
>>
>> On Wed, Apr 4, 2018 at 9:36 PM, Thomas <[email protected]> wrote:
>>
>>> I tested my code again today (I was preparing something to post for you
>>> on github) and surprise!: The CN1 app was able to communicate with my
>>> socket.io server and I the javascript logs where correctly output in my
>>> device adb logcat (meaning BrowserComponent.execute() javascript calls
>>> where correctly executed ). I really don't know why it did not work
>>> yesterday and does today as I didn't change anything in my code (either in
>>> the CN1 app or the server). That is a complete mystery.
>>> Anyway, I am now facing another issue.  My CN1 app is now able to send
>>> the socket.io handshake request to my server (that correctly receved
>>> it, as I can see in it's log) but the handshake is unable to succeed due to
>>> a CORS issue (only on the device, still works on the simulator. And I must
>>> say that the simulator and the server are run on 2 different PCs (and have
>>> 2 different IPs) so the situation is strictly the same in what concerns
>>> CORS when run on the simulator or on my real android device).
>>> In the adb logcat, I can see this error message:
>>>  [main] 0:0:2,36 - [ERROR] Failed to load http://192.168.8.100:3030/sock
>>> et.io/?EIO=3&transport=polling&t=MAJ14W8: Response to preflight request
>>> doesn't pass access control check: The 'Access-Control-Allow-Origin' header
>>> has a value 'null' that is not equal to the supplied origin. Origin 'null'
>>> is therefore not allowed access. On line 0 of file:///android_asset/socket_i
>>> o.html
>>> (192.168.8.100:3030 being my server url  and socket_io.html my embeded
>>> CN1 asset that loads the socket.io.js embeded asset script)
>>>
>>> This is kind of strange as if I call http://192.168.8.100:3030
>>> /socket.io/?EIO=3&transport=polling&t=MAJ14W8 inside my chrome
>>> browser,  in the response header I can see Access-Control-Allow-Origin: *
>>> so I don't get it why the BrowserComponent has a 'null' value for it...
>>> Do you already experienced using a javascript lib with CORS permissions
>>> inside the BrowserComponent on android?
>>>
>>> I can post something on github for you to test if you want to (and have
>>> the time to look at it) but as my socket.io server is not public yet,
>>> you would also have to run a small socket.io server (or to find a
>>> public one) to be able to see the issue (I can post the code of a small
>>> soket.io server to use with the test CN1 app but it would requiere you
>>> to install node.js)
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "CodenameOne Discussions" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> Visit this group at https://groups.google.com/grou
>>> p/codenameone-discussions.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/codenameone-discussions/55d571c9-f7b7-41ce-b64f-ec120c0a
>>> ecd9%40googlegroups.com
>>> <https://groups.google.com/d/msgid/codenameone-discussions/55d571c9-f7b7-41ce-b64f-ec120c0aecd9%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Steve Hannah
>> Software Developer
>> Codename One
>> http://www.codenameone.com
>>
> --
> You received this message because you are subscribed to the Google Groups
> "CodenameOne Discussions" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> Visit this group at https://groups.google.com/
> group/codenameone-discussions.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/codenameone-discussions/c55da377-d38b-43bf-831b-
> 5dbc455ad4de%40googlegroups.com
> <https://groups.google.com/d/msgid/codenameone-discussions/c55da377-d38b-43bf-831b-5dbc455ad4de%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Steve Hannah
Software Developer
Codename One
http://www.codenameone.com

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/CAGOYrKW13Z8SaUHYz1f-rACL36Ezp2V8rCANHYg9s38GD5RfPA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to