Question

I'm trying to use the new Socket API for Chrome extensions, and I'm encountering a confusing error. The manifest for my sample app looks like this:

{
  "name":"Yet Another Socket App",
  "version":"0.0.1",
  "manifest_version":2,
  "permissions":[
    "experimental", "socket"
  ],
  "app":{
    "launch":{
        "local_path":"index.html"
    }
  }
}

The app is loading (i.e., no error alerts), but a warning appears beneath its entry in chrome://extensions: 'socket' is not allowed for specified package type (theme, app, etc.).

Notes: index.html exists and is a simple HTML document (and chrome.socket is indeed undefined within it). I have enabled experimental APIs via chrome://flags. I am running the Dev channel of Chrome (v22.0.1229.6 dev) on Ubuntu.

Is this a momentary hiccup in socket support (this is the Dev channel, after all), or am I setting up my app incorrectly somehow? Also, I had to uninstall Chrome Stable to install Dev; is it possible that apt-get purge google-chrome-stable and rm -rf ~/.config/google-chrome was insufficient to clear out every piece of the Stable channel?

Was it helpful?

Solution

I had the same problem trying to recreate this example from Google: http://developer.chrome.com/trunk/apps/app_network.html

Chrome always said

Invalid value for 'permissions[1]'

The correct manifest file is available in their sample App: https://github.com/GoogleChrome/chrome-app-samples/tree/master/udp

After changing permissions in manifest.json to

"permissions": [
    "experimental",
    {"socket": [
        "udp-send-to"
    ]},
    "app.window"
]

I can now access the socket object in Chrome version 23 or higher:

var socket = chrome.socket || chrome.experimental.socket;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top