Socket API

1,010 views
Skip to first unread message

boule...@eisti.eu

unread,
Jul 8, 2014, 7:36:17 AM7/8/14
to native-cli...@googlegroups.com
Hello,

I have a problem when I try to use tcp_socket api or udp_socket api.

I tried with the examples/api/socket file, I launch google chrome that way : google-chrome --enable-nacl --allow-nacl-socket-api=* (I tried with --allow-nacl-socket-api=localhost too)
And I still get the following error :

"Host localhost cannot use socket API or destination is not allowed"

and

Starting server on port: 8080 
server: Bind failed with: -7
(another port doesn't change anything)

I have :
            "tcp-listen:*:*",
            "tcp-connect",
            "resolve-host",
            "udp-bind:*:*",
            "udp-send-to:*:*"

in manifest.json

And Websockets are working perfectly.

Am I missing something ?

Ben Smith

unread,
Jul 8, 2014, 1:28:43 PM7/8/14
to native-cli...@googlegroups.com
I just tried this, and I get the same error as you if I use --allow-nacl-socket-api=*.

If I use --allow-nacl-socket-api=localhost it works, but only if I browse to http://localhost:5103/... If I use http://127.0.0.1:5103/... it fails with

Host 127.0.0.1 cannot use socket API or destination is not allowed

By the way, the manifest settings are only important if you're running as a Chrome App. When you use the --allow-nacl-socket-api flag, you are bypassing the normal permissions.

Also, websockets don't require any special permissions, so they will always work.

Could you give a bit more information about your setup? What version of Chrome and OS? What version of the NaCl SDK? Are you using NaCl or PNaCl? Which toolchain?

boule...@eisti.eu

unread,
Jul 9, 2014, 2:58:23 AM7/9/14
to native-cli...@googlegroups.com

I tried with "--allow-nacl-socket-api=localhost" and http://localhost:5103/... and it fails.

OS :
Ubuntu 13.10
Chrome :
35.0.1916.153(OfficialBuild 274914)
Nacl SDK :
pepper_35
Toolchain :
linux_x86_glibc






Sam Clegg

unread,
Jul 16, 2014, 3:06:33 PM7/16/14
to native-cli...@googlegroups.com
On Tue, Jul 8, 2014 at 11:58 PM, <boule...@eisti.eu> wrote:

I tried with "--allow-nacl-socket-api=localhost" and http://localhost:5103/... and it fails.

What errors if any do you see on stdout?

Are you sure that your page is not  being loaded in an existing chrome instance (in this case the command line flags won't work).  The best way to ensure that you are launching a new/unique chome instance is to specify a unique --user-data-dir=<directory>.  This also ensures that you see all the stdout from the chrome process.

cheers,
sam

 

OS :
Ubuntu 13.10
Chrome :
35.0.1916.153(OfficialBuild 274914)
Nacl SDK :
pepper_35
Toolchain :
linux_x86_glibc






--
You received this message because you are subscribed to the Google Groups "Native-Client-Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to native-client-di...@googlegroups.com.
To post to this group, send email to native-cli...@googlegroups.com.
Visit this group at http://groups.google.com/group/native-client-discuss.
For more options, visit https://groups.google.com/d/optout.

boule...@eisti.eu

unread,
Jul 18, 2014, 3:06:19 AM7/18/14
to native-cli...@googlegroups.com

On stdout : "[4123:4123:0718/085133:ERROR:pepper_socket_utils.cc(64)] Host localhost cannot use socket API or destination is not allowed"

I am not sure to understand what you mean (about chrome instances).


I tried to "make run" in pepper35/examples/api/  => Starting up python webserver.
Then "google-chrome-stable --allow-nacl-socket-api=localhost http://localhost:5103/socket/"
And it fails with the error I wrote.

But when I try to "make run" directly in pepper35/examples/api/socket, it launches google-chrome and It works fine.

At least, I tried with -user-data-dir=<directory> with the following command line :
"google-chrome-stable --allow-nacl-socket-api=localhost --user-data-dir=/home/.config/google-chrome/Default http://localhost:5103/socket/"
And I have a new error :
[6075:6075:0718/090436:ERROR:simple_message_box_views.cc(208)] Unable to show a dialog outside the UI thread message loop: Failed To Create Data Directory - Google Chrome cannot read and write to its data directory:
Then, still the same :
[6075:6075:0718/090439:ERROR:pepper_socket_utils.cc(64)] Host localhost cannot use socket API or destination is not allowed

Victor Khimenko

unread,
Jul 18, 2014, 4:23:14 AM7/18/14
to Native Client Discuss
On Fri, Jul 18, 2014 at 11:06 AM, <boule...@eisti.eu> wrote:

On stdout : "[4123:4123:0718/085133:ERROR:pepper_socket_utils.cc(64)] Host localhost cannot use socket API or destination is not allowed"

I am not sure to understand what you mean (about chrome instances).

Chrome only parses all the flags ONCE: when it starts for the first time. If you try to start Chrome for the second time it'll find the first instance of Chrome and will pass URL to it. Flags will be ignored in such usecase.

But of course that only happens if you are running versions of Chrome which share the data dir. Two different versions of Chrome could not use the same data dir simultaneusly, that's why aforementioned mechanism was developed... by Netscape 30 years ago - it's not a Chrome invention.
 

I tried to "make run" in pepper35/examples/api/  => Starting up python webserver.
Then "google-chrome-stable --allow-nacl-socket-api=localhost http://localhost:5103/socket/"
And it fails with the error I wrote.

But when I try to "make run" directly in pepper35/examples/api/socket, it launches google-chrome and It works fine.

At least, I tried with -user-data-dir=<directory> with the following command line :
"google-chrome-stable --allow-nacl-socket-api=localhost --user-data-dir=/home/.config/google-chrome/Default 
 
Are you positively sure that there are NO instances of Chrome which are using that data dir when you start that command? From what I'm seeing that's default place for Chrome's user-data-dir which means that, most likely, any stray instances of Chrome will use exactly that one and thus will ignore llow-nacl-socket-api command line.

boule...@eisti.eu

unread,
Jul 23, 2014, 8:58:55 AM7/23/14
to native-cli...@googlegroups.com

Are you positively sure that there are NO instances of Chrome which are using that data dir when you start that command? From what I'm seeing that's default place for Chrome's user-data-dir which means that, most likely, any stray instances of Chrome will use exactly that one and thus will ignore llow-nacl-socket-api command line.

I really believe my command line is not ignored :
When I use " google-chrome-stable --allow-nacl-socket-api=localhost --no-sandbox" Google chrome warns me with :
"[10760:10760:0723/145656:ERROR:browser_main_loop.cc(163)] Running without the SUID sandbox!"

But I still have the same error :
[10760:10760:0723/145826:ERROR:pepper_socket_utils.cc(63)] Host localhost cannot use socket API or destination is not allowed

David Michael

unread,
Jul 24, 2014, 1:01:23 PM7/24/14
to native-cli...@googlegroups.com
Can you try some variations on your parameter and see if you can get it to work?
E.g.:
--allow-nacl-socket-api="http://localhost"
--allow-nacl-socket-api="127.0.0.1"
--allow-nacl-socket-api="http://127.0.0.1"
...and make sure you navigate to the same URL you specify on the command-line (not an alias)
You should ultimately be getting in to this code:
...and it's not clear to me how it's failing. If GURL doesn't recognize it as a valid URL, that would cause the problem (but if the missing http:// is the problem, I don't know why it worked for binji@).


--
Reply all
Reply to author
Forward
0 new messages