Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 613
Lanston Avatar asked Feb 02 '12 02:02

Lanston


People also ask

Could not establish connection receiving end does not exists?

Receiving End Does Not Exist Error Happening? This error usually happens due to a problem with a specific Chrome extension inside your main document. The program cannot establish a connection, and many web developers are usually faced with this error while working on Chrome.

Could not establish connection receiving end does not exist web scraper?

The "Could not establish connection." occurs after a page load when Web Scraper tries to extract data from the specific URL and the page hasn't loaded. This can be related to loosing network connection or being blocked by the site in their firewall. If the error happens in browser extension, the page will be skipped.

What is Chrome background script extension?

The background script should be viewed as "running in the background of the Chrome browser". Your desired effect (running a script for every page) is actually a task for content scripts. To learn more, read https://developer.chrome.com/extensions/overview.html#arch. Follow this answer to receive notifications.

How do I send a message to content script?

When sending a message to the content script, we need to specify which tab to send it to. Therefore, we need to retrieve the active tab information first, and then use tabs. sendMessage . To use the tabs API and to have access to the active tab, you need to add tabs and activeTab under permissions in your manifest.


1 Answers

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.

like image 128
Neil Avatar answered Sep 19 '22 05:09

Neil