Mastodon 4.2.10 and MastoUnexpectedError: The server returned data with an unknown encoding. The server may be down. #1144
Unanswered
GerritKuilder
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Hi @GerritKuilder, As of Masto.js v6, we have refined the method to subscribe to a streaming API to more performant and intuitive design. Here is the latest example: If you want to subscribe to a user, you can code as follows: import { createStreamingAPIClient } from "masto";
const streaming = createStreamingAPIClient({
// If you don't know what streaming API URL is, refer /api/v2/instance of your instance
streamingApiUrl: "<STREAMING API URL>",
accessToken: "<TOKEN>",
});
const events = streaming.user.subscribe();
for await (const event of events) {
switch (event.event) {
case "update": {
console.log("new post", event.payload.content);
break;
}
case "delete": {
console.log("deleted post", event.payload);
break;
}
// of course, you can consume other types of events as well
default: {
break;
}
}
} If you still have a problem, feel free to write a comment here. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi All,
just started a new project and also upgraded my mastodon server, the server is up and running, and doing fine but the new project return the above error when running the following:
Am I missing something or can I get more details of the error?
Edit:
it seems to be the stream user that is failing, also failing for my other projects:
const stream = await client.v1.stream.streamUser();
Logs
Kind regards,
Gerrit Kuilder
Beta Was this translation helpful? Give feedback.
All reactions