admin管理员组文章数量:1395461
I am trying to create a tcp
socket in the background script of my app.
The error is (first line in 1.js
):
Uncaught TypeError: Cannot read property 'tcp' of undefined
Background script 1.js
:
chrome.sockets.tcp.create({}, function(createInfo) {
chrome.sockets.tcp.connect(createInfo.socketId,
"127.0.0.1", 4005, function(socketInfo) {
});
});
Manifest file :
{
"manifest_version": 2,
"name": "UDP TEST",
"version": "1.0",
"app": {
"background": {
"scripts": ["1.js"]
}
},
"permissions": [
{
"socket": [
"tcp-listen:*:*",
"tcp-connect",
"resolve-host"
]
}
]
}
Can anyone help me? Thanks!
I am trying to create a tcp
socket in the background script of my app.
The error is (first line in 1.js
):
Uncaught TypeError: Cannot read property 'tcp' of undefined
Background script 1.js
:
chrome.sockets.tcp.create({}, function(createInfo) {
chrome.sockets.tcp.connect(createInfo.socketId,
"127.0.0.1", 4005, function(socketInfo) {
});
});
Manifest file :
{
"manifest_version": 2,
"name": "UDP TEST",
"version": "1.0",
"app": {
"background": {
"scripts": ["1.js"]
}
},
"permissions": [
{
"socket": [
"tcp-listen:*:*",
"tcp-connect",
"resolve-host"
]
}
]
}
Can anyone help me? Thanks!
Share Improve this question asked Feb 8, 2015 at 10:52 KaBaKaBa 2853 silver badges16 bronze badges 2- Ok, we will need to spam the Chrome team so that they will know many people need Chrome Extensions to support UDP/TCP. GO to docs.google./forms/d/e/… and type this in: – Pacerier Commented Jan 30, 2017 at 16:31
-
.."
We need chrome extensions to support UDP/TCP sockets. I can't migrate chrome.sockets to extensions dammit. Native messaging is not a real solution to chrome.sockets. Does it even make sense that I would have to create a Windows native app just to receive "UDP and TCP messages" from Chrome extension via Chrome's native message and then pass on those requests to the actual UDP and TCP? The performance hit is Huge (which would defeat the whole purpose of UDP and TCP in the first place)!
" and hit submit suggestion. – Pacerier Commented Jan 30, 2017 at 16:31
1 Answer
Reset to default 4You have wrong permissions in manifest. Look up the Chrome API help: https://developer.chrome./apps/sockets_tcp (and specificaly for manifest: https://developer.chrome./apps/manifest/sockets)
The permissions should read "sockets". You are using the new "sockets" API, but in your manifest you are refering to old "socket" permissions (https://developer.chrome./apps/socket)
Your manifest permissions should read:
"permissions": [{
"sockets": {
"tcp": {
"connect": "127.0.0.1:4005"
}
}
}]
本文标签: javascriptWhy chromesocketstcpcreate() does not work in app background scriptStack Overflow
版权声明:本文标题:javascript - Why chrome.sockets.tcp.create() does not work in app background script? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744641440a2617145.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论