Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with *some* instances: how to debug? #392

Open
bortzmeyer opened this issue Jan 8, 2025 · 2 comments
Open

Not working with *some* instances: how to debug? #392

bortzmeyer opened this issue Jan 8, 2025 · 2 comments

Comments

@bortzmeyer
Copy link

I hosted two bots (read/write bots) at botsin.space which is now closed. Everything worked fine there. I'm looking for a new hosting but I encounter problems with the two first Mastodon instances I tried.

One one instance, I can connect but I get no heartbeats. The instance admin does not know why. I also does not receive notifications when I write to the bot.

On the other instance, I get "('Mastodon API returned error', 404, 'Not Found', 'Endpoint not found.') when calling stream_healthy() . I find no way to know the URL which was actually used by Mastodon.py (the instance admin requests that). I do not find a "debug verbose mode". (The instance admin says that streaming is active and running.)

Complete source code is at https://framagit.org/bortzmeyer/mastodon-DNS-bot/

I'm aware that this bug report is too vague but I'm willing to send more information, if you have ideas how to get more information. (I am not the admin of the instances and I am not sure they have the time to look into it. I know nothing about Mastodon administration.)

Recommandations for bot hosting are also welcome;

@Ryuno-Ki
Copy link

Ryuno-Ki commented Jan 8, 2025

stream_healthy() is defined in streaming_endpoint.py:

def stream_healthy(self) -> bool:

It calls GET '/api/v1/streaming/health'

It's documented with Mastodon.

The „debug verbose mode” refers likely to

if self.debug_requests:
print(f'Mastodon: Request to endpoint "{base_url}{endpoint}" using method "{method}".')
print(f'Parameters: {params}')
print(f'Headers: {headers}')
print(f'Files: {files}')

You can turn it on during instantiation:

https://mastodonpy.readthedocs.io/en/stable/04_auth.html?highlight=debug_requests#authentication

That would be in register.py.

@bortzmeyer
Copy link
Author

The „debug verbose mode” refers likely to

if self.debug_requests:
print(f'Mastodon: Request to endpoint "{base_url}{endpoint}" using method "{method}".')
print(f'Parameters: {params}')
print(f'Headers: {headers}')
print(f'Files: {files}')

You can turn it on during instantiation:

Thanks https://framagit.org/bortzmeyer/mastodon-DNS-bot/-/commit/3685ebe482a33c20beefadb917b3d5cee849f3fe I can now see that there is indeed an issue on the instance:

Mastodon: Request to endpoint "https://m.g3l.org/api/v1/streaming/health" using method "GET".
Parameters: {}
Headers: {'Authorization': 'Bearer XXXXX', 'User-Agent': 'mastodonpy'}
Files: {}
Mastodon: Response received with code 404.
response headers: {'Date': 'Wed, 08 Jan 2025 12:13:16 GMT', 'Server': 'Apache', 'X-Powered-By': 'Express', 'X-Request-Id': 'a473058e-118b-40a9-ab41-4b3f888793fe', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Headers': 'Authorization, Accept, Cache-Control', 'Access-Control-Allow-Methods': 'GET, OPTIONS', 'X-Content-Type-Options': 'nosniff', 'Content-Type': 'text/html; charset=utf-8', 'Content-Length': '146', 'Strict-Transport-Security': 'max-age=63072000', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'Content-Security-Policy': "base-uri 'none'; default-src 'none'; font-src 'self' https://m.g3l.org; img-src 'self' https: data: blob: https://m.g3l.org; style-src 'self' 'unsafe-inline' https://m.g3l.org; media-src 'self' https: data: https://m.g3l.org; frame-src 'self' https:; manifest-src 'self' https://m.g3l.org; connect-src 'self' blob: https://m.g3l.org wss://m.g3l.org; script-src 'self' https://m.g3l.org", 'Keep-Alive': 'timeout=5, max=98', 'Connection': 'Keep-Alive'}
Response text content: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET //health</pre>
</body>
</html>

2025-01-08 13:13:16,557 - CRITICAL - Unexpected error MastodonNotFoundError in the driver "('Mastodon API returned error', 404, 'Not Found', 'Endpoint not found.')"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants