Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

google chrome extension - Port error: Could not establish connection. Receiving end does not exist. In Chromiume

I'm developing an extension in Chrome, and there's a problem. In my inject.js, I make a request like:

chrome.extension.sendRequest({command:'skip'},callback)

and in my `background.js I simply add a request Listener like:

chrome.extension.onrequest.addListener(function(req,sender,res){console.log("procession"})

But there's an error:

Port error: Could not establish connection. Receiving end does not exist

It seems a bug in chrome? PS:
part of my manifest.json

"background": {
    "scripts": ["background.js"]
},
"content_scripts": [
  {
    "matches": ["< all_urls >"], 
    "js": ["inject.js"]
  }
],

I'm in Chromium 17, and I tried reloading the extension, reopening the browser... nothing happened
some one get some ideas?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This isn't always the cause, but if you have an error in your background.js, you should check this link:

Inspect views: _generated_background_page.html

in the Extensions page, which will show you any JavaScript errors.

This was preventing my connections from getting established.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...