Dev tools of the site, dev tools of the service worker and background.js can open a websocket connection perfectly fine. The content scripts however, will trigger onerror, then onclose immediately. I am using Manifest 2, with permission to <all_urls>, content script matching the website correctly and onclose code is 1006.
I am not receiving any error message. Quite a simple code;
const socket = new WebSocket("wss://my.website.com/ws/"); socket.addEventListener("error", (e) => { console.log("Error:", e); }); socket.addEventListener("close", (e) => { console.log("Closed", e); });
This only happens in Firefox and mobile version of it. Chrome, Opera, Kiwi browser and some others don’t have this issue, they use Manifest 3.
irşat akdeniz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.