Reputation: 11
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.
Edit: I tested Manifest v3 on Firefox and it fixes the problem. But it's only supported in latest browser versions. I would like to keep using Manifest v2 for some time.
Upvotes: 1
Views: 96