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

Multiple calls to refreshSession failing #54

Open
1 of 5 tasks
jguadagno opened this issue Dec 28, 2024 · 5 comments
Open
1 of 5 tasks

Multiple calls to refreshSession failing #54

jguadagno opened this issue Dec 28, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@jguadagno
Copy link
Contributor

Bug report

Details

Describe the bug

After installing release 0.1.3-prerelease I am getting a lot of failed (429) POST calls to https://puffball.us-east.host.bsky.network/xrpc/com.atproto.server.refreshSession. Around 3 million a day, some are successful, but most are failing.

image

Expected behavior

The agent should not refresh the token so frequently

Actual behavior

The agent attempts to refresh the token multiple times a second.

Helpful Extra information

What operating system(s) are you using?

  • Windows
  • macOS
  • Ubuntu
  • Other Linux
  • Other (specify below)

Reproduction code

I have the code for the login available here: https://github.com/jguadagno/jjgnet-broadcast/blob/c43206129fbc9056659115f1770f1da747fe668a/src/JosephGuadagno.Broadcasting.Managers.Bluesky/BlueskyManager.cs#L20

@jguadagno jguadagno added bug Something isn't working needs triage This issue has not been triaged labels Dec 28, 2024
@blowdart blowdart removed the needs triage This issue has not been triaged label Jan 2, 2025
@blowdart
Copy link
Owner

blowdart commented Jan 2, 2025

The agent should not refresh the token so frequently

@jguadagno There's an understatement :)

Given you are creating a new agent instance which in turn creates a new session with every operation and then throwing the agent away it shouldn't be refreshing a session at all.

I'm wonder if the GC hasn't caught up yet, and they're all hanging around refreshing until they get collected.

A couple of things to try

  1. The quick fix - turn session refresh off as you don't need it with your approach. Also as they're disposable, wrap the agent pieces in using.

  2. If you can, consider a longer lived agent. The JWTs issued by BlueSky last for two hours, you could have a more central agent instantiation and pass the agent instance around, rather than create one each time, which is a slow process due to it resolving the handle and PDS.

If neither of those work I'm adding more logging to the refresh code (and giving each session an internal identifier to help correlate), and we'll start gathering logs to see what the heck is going on.

@jguadagno
Copy link
Contributor Author

The thing that is weird is that the method (Azure Function) to post a Bluesky skeet should only be called twice a day or additionally if there is a recent blog post/video, which there hasn't been.

I've since updated the code and added a using declaration around the creation of the agent, since I only need it for the posting of the skeet.

@jguadagno
Copy link
Contributor Author

The thing that is weird is that the method (Azure Function) to post a Bluesky skeet should only be called twice a day or additionally if there is a new blog post/video, which there hasn't been.

I've since updated the code and added a using declaration around the creation of the agent, since I only need it for the posting of the skeet.

@blowdart
Copy link
Owner

blowdart commented Jan 2, 2025

Don't you head down that route of calling them skeets!

Let's see if that solves it, if it doesn't, I'll build a version with the debug logging, which presumably you can hook up in a function somewhere

@blowdart blowdart self-assigned this Jan 2, 2025
@blowdart
Copy link
Owner

blowdart commented Jan 5, 2025

#62 might be the root cause here.

v0.2.1-prerelease is on nuget now if you want to try that as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants