neet / masto.js

🐘 Universal Mastodon API client for JavaScript
https://neet.github.io/masto.js/
MIT License
726 stars 46 forks source link

Unknown Encoding #1145

Closed fishcharlie closed 1 month ago

fishcharlie commented 1 month ago

I keep getting an unknown encoding error.

app-1  | MastoUnexpectedError: The server returned data with an unknown encoding. The server may be down.
app-1  |     at HttpNativeImpl.<anonymous> (/project/node_modules/masto/dist/index.cjs:941:27)
app-1  |     at Generator.next (<anonymous>)
app-1  |     at /project/node_modules/masto/dist/index.cjs:78:71
app-1  |     at new Promise (<anonymous>)
app-1  |     at __awaiter (/project/node_modules/masto/dist/index.cjs:74:12)
app-1  |     at HttpNativeImpl.createError (/project/node_modules/masto/dist/index.cjs:937:16)
app-1  |     at HttpNativeImpl.<anonymous> (/project/node_modules/masto/dist/index.cjs:920:34)
app-1  |     at Generator.next (<anonymous>)
app-1  |     at fulfilled (/project/node_modules/masto/dist/index.cjs:75:58)
app-1  |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Here is some very rough example code of what I'm trying to do:

import { createStreamingAPIClient as MastoStream } from "masto";
const masto = MastoStream({
    "accessToken": socialNetwork.credentials.password,
    "streamingApiUrl": `wss://streaming.mastodon.social/api/v1/streaming`
});
convertAsyncIterableToCallback(masto.direct.subscribe().values(), (err, item) => {
    console.log(item);
});

function convertAsyncIterableToCallback(
    asyncIterable,
    callback
): void {
    (async () => {
        try {
            for await (const item of asyncIterable) {
                callback(null, item);
            }
            callback(null, null); // Signal end of iteration
        } catch (err) {
            callback(err instanceof Error ? err : new Error(String(err)), null);
        }
    })();
}

Any ideas what could be going wrong here? It really doesn't seem like Mastodon.social is down.

fishcharlie commented 1 month ago

It actually looks like this might be caused when sending a private direct message to my Mastodon account using Ivory when using Proxyman.

Absolutely no idea why that would be happening tho...

neet commented 1 month ago

Hi @fishcharlie, thank you for reporting an issue.

It seems that your streamingApiUrl is incorrect. The proper streamingApiUrl for the instance https://mastodon.social is wss://streaming.mastodon.social which does not contain paths after the hostname. You can obtain the configurations of your instance from /api/v2/instance.

If you still have any problem, feel free to write a comment here.

neet commented 1 month ago

Closing due to inactivity. Feel free to reopen it if you still have a problem