titaniumnetwork-dev / Ultraviolet

A highly sophisticated proxy used for evading internet censorship or accessing websites in a controlled sandbox using the power of service-workers. Works by intercepting HTTP requests with a service worker script that follows the TompHTTP specifications.
https://docs.titaniumnetwork.org/proxies/ultraviolet
GNU Affero General Public License v3.0
565 stars 4.13k forks source link

Ultraviolet Error With Service Worker #127

Closed ClarrieO5 closed 6 months ago

ClarrieO5 commented 7 months ago

image

That image pops up each time I then go to inspect and go to application. And clear web data and stuff. It works. But it happens every time, on multiple proxies that run ultraviolet. E.g emerald, ruby (only occasionally)

Evanbalam11 commented 7 months ago

Especially Shadow Tabbed for me at least

proudparrot2 commented 7 months ago

This is, I think, a limitation with BareMux, which Ultraviolet uses internally. Specifically the fact that it doesn't properly register the transport (the software that transports the requests) the first time you load the page. Once it does load, you should be good to go and probably won't have it happen again. doing Ctrl + Shift + R once or twice fixes it as well.

I personally have noticed this a lot and am trying to find a solid way to work around this for new users.

IncognitoTGT commented 7 months ago

@Percslol what was the fix for this again

Percslol commented 7 months ago

This is, I think, a limitation with BareMux, which Ultraviolet uses internally. Specifically the fact that it doesn't properly register the transport (the software that transports the requests) the first time you load the page. Once it does load, you should be good to go and probably won't have it happen again. doing Ctrl + Shift + R once or twice fixes it as well.

I personally have noticed this a lot and am trying to find a solid way to work around this for new users.

Your issue is setting the transport before the service worker is ready, I already updated the ultraviolet docs to include this fix but its as easy as setting your transport when the service worker is ready like shown in the example.

navigator.serviceWorker.ready.then((sw) => {
    SetTransport("EpxMod.EpoxyClient", { wisp: "wss://wisp.mercurywork.shop/" });
    SetTransport("BareMod.BareClient", "https://example.com/bare/");
});
proudparrot2 commented 7 months ago

I've been setting it in a .then after the register function, but I'll try this out

Percslol commented 7 months ago

I've been setting it in a .then after the register function, but I'll try this out

Yeah turns out this is not really a fix as that promise only gets returned if the service worker is intercepting the current page.

IncognitoTGT commented 7 months ago

This is the other react related fix (which can be adapted to other frameworks like solid)


export default function AppRoutes() {
    const [init, setInit] = useState(false);
    const [config] = useConfig("proxy");
    useEffect(() => {
        if ("serviceWorker" in navigator) {
            navigator.serviceWorker
                .register("/sw.js", {
                    scope: "/~/",
                })
                .then(() => {
                    console.log(
                        "\x1b[34;49;1m[Ephemeral] \x1B[32mINFO: Service workers registered",
                    );
                    BareMux.registerRemoteListener(navigator.serviceWorker.controller);
                    BareMux.SetTransport(transports[config.transport], {
                        wisp: config.wispServer,
                    });
                                        setInit(true)
                })
                .catch((err) => {
                    console.error(
                        "\x1b[34;49;1m[Ephemeral] \x1B[31mERROR: Service workers registration failed",
                        err,
                    );
                });
        } else {
            console.error(
                "\x1b[34;49;1m[Ephemeral] \x1B[31mERROR: Service workers are not supported on this device",
            );
        }
    }, [config]);
    return init ? <RouterProvider router={routes} /> : null;
}
Percslol commented 6 months ago

this issue was resolved in 3.1.1, try updating uv-app if you are using it or updating your uv version if its your own custom frontend

closing as completed