how to using socket api in hosted app of NaCl

365 views
Skip to first unread message

정한구

unread,
Aug 23, 2015, 4:49:54 AM8/23/15
to Chromium Apps
Hi. 

I create NaCl application using nacl_io sample.

I checked that nacl_io socket is work in packaged app. but, it didn't work in hosted app.

This app was registered in the CWS.

how to work this app?

my hosted app link is as below

I checked as below
1.  run chrome using flag (--allow-nacl-socket-api=61.34.112.49) is work.

2. permissions of sockets was inserted in manifest.json  

my manifest.json is as below

{
    "name": "ppStreamBridge",
    "version": "0.9.8",
    "manifest_version": 2,
    "description": "ppStreamBridge",
    "offline_enabled": false,
    "icons": {
        "128": "icon128.png"
    },
    "app": {
        "background": {
            "scripts": [
                "background.js"
            ]
        },
    },
    "launch": {
        "web_url": "http://61.34.112.49/ppStreamBridge/"
    },
    "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjtdlyjf7XJplSl/hUtiOtojpQ/sJDKI4fFM+AiOSIF7S2Eba/2YBM9oPCsw9vCckV1yJ6EEWJF8KvJEMXj7djHLI4JzvwUW2ejKXRBr5IcgH2F+aY8loqg21R22j0ZtGPsIiWq0GaM+vepmi4m6m3OiaIwUEQHqRyOt6orsSsweePtiLOivh6ziZoTEf1gnHmKeHeuYTi+mYRwvJ7tc0M//JsDEbGP1qVi+uIEQjVH6envd8F5nx5O4iWpIFUeKscgHelk4F3b4A+nfc5nPe7RraJcFdzKoM1nxKdMUmjVN8pn0+IdM76axVepNZAOM5pfgoGHSXdkgEG1s8M/pzIwIDAQAB",
    "permissions": [
        "unlimitedStorage",
        {
            "socket": [
                "tcp-listen:*:*",
                "tcp-connect",
                "resolve-host",
                "udp-bind:*:*",
                "udp-send-to:*:*"
            ]
        }
    ]
}

Thanks for the help.

Victor Khimenko

unread,
Aug 23, 2015, 6:58:51 AM8/23/15
to 정한구, Chromium Apps
You are not the first one to hit this problem, apparently. STFW:

"socket" is permission for old-style deprecated API, permissions for new-style API is called "sockets":
 

정한구

unread,
Aug 23, 2015, 8:52:24 PM8/23/15
to Chromium Apps, jongh...@gmail.com

Hi khim

Thank you for your help.

I edit my manifest.json and reregist to CWS

But, it doesn't work

Result is gethostbyname failed, error is "Unknown error in gethostbyname: 0.".

My manifest.json is as below

"permissions": [
        "unlimitedStorage",
        {
            "sockets": [
                {
                    "udp": [
                        {
                            "bind": "*",
                            "send": "*"
                        }
                    ],
                    "tcp": {
                        "connect": "*"
                    }
                }
            ]
        }
    ]
 
Thanks for your help

정한구

unread,
Aug 23, 2015, 10:44:23 PM8/23/15
to Chromium Apps, jongh...@gmail.com
One more infomation.

I apply edited manifest.json and check packaged app

but it's doesn't work too :(

how can i fix it?

Ian Clelland

unread,
Aug 24, 2015, 11:23:09 AM8/24/15
to 정한구, Chromium Apps
For the chrome.sockets API, the "sockets" key in the manifest file shouldn't be nested under "permissions", it is a top-level item.

See https://developer.chrome.com/apps/manifest for the full format, but essentially, instead of:

"permissions": [
        "unlimitedStorage",
        {
            "sockets": [
                {
                    "udp": [
                        {
                            "bind": "*",
                            "send": "*"
                        }
                    ],
                    "tcp": {
                        "connect": "*"
                    }
                }
            ]
        }
    ]

you should have something like

"permissions": ["unlimitedStorage"],
"sockets": {
    "udp": {
        "bind": "*",
        "send": "*"
    },
    "tcp": {
        "connect": "*"
    }
}

(It's been a while since I've used it, so I don't know if that syntax is *exactly* correct -- read the docs carefully and it should explain it all.)

--
You received this message because you are subscribed to the Google Groups "Chromium Apps" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-app...@chromium.org.
To post to this group, send email to chromi...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-apps/.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.

Vitaly Ivanov

unread,
May 2, 2016, 12:25:07 PM5/2/16
to Chromium-Apps-Announce
It's an old question, but... I have a problem with socket binding (PNaCl app working via nacl_io) - it works if I serve it locally or on AWS and open the page with Chrome/Chromium configured properly (--allow-nacl-socket-api command line arg), it works as a packaged app (as long as the manifest is "old style"), but if I publish it as a hosted app via Google CWS (which for some reason takes 6-8 hours instead of promised "up to 60 min"), socket bind() just returns 13 (access/permission denied). I tried "old style", "new style", "old style" + "new style" in one manifest.json - nothing helps.
I wonder if it's possible at all to distribute this kind of app as hosted? When I install it, I'm not even asked if I'm alright with giving this app permission to do all sorts of network stuff (I get this warning when installing it as a packaged app), so it looks like for hosted apps the permission section is just silently ignored. 
 

Vitaly Ivanov

unread,
May 2, 2016, 3:17:33 PM5/2/16
to Chromium-Apps-Announce
I've stumbled upon a detail I missed previously: https://developer.chrome.com/webstore/choosing. There's a box "Do you want to use chrome.* APIs?", if yes you're left with the only option - a packaged app. I guess this answers my question about sockets in hosted apps 

Rassulzhan

unread,
Nov 3, 2016, 10:12:59 PM11/3/16
to Chromium-Apps-Announce, jongh...@gmail.com
Hi, I am also developing PNaCl plugin, but have the same problem with socket API.
Did you solve that problem? 

I will wait for your reply and any advice to solve this problem, because I am trying to handle this problem for the two weeks already.

Thanks

Best regards,
Rassulzhan

Imran

unread,
Jun 3, 2017, 1:28:00 PM6/3/17
to Chromium-Apps-Announce, jongh...@gmail.com
How does the NaCl port of OpenSSH get around this?
The secure shell extension is not an app, and doesn't request any special permissions - but it's able to access raw sockets.
How does that work?

thanks,
imran

PhistucK

unread,
Jun 4, 2017, 12:18:19 PM6/4/17
to Imran, Chromium-Apps-Announce, jongh...@gmail.com
It uses private APIs, that are not available to normal applications. :(


PhistucK

--
You received this message because you are subscribed to the Google Groups "Chromium-Apps-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-apps+unsubscribe@chromium.org.

To post to this group, send email to chromi...@chromium.org.
Reply all
Reply to author
Forward
0 new messages