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

Uri and '@' links #19

Open
JeepNL opened this issue Nov 12, 2024 · 17 comments · May be fixed by #20
Open

Uri and '@' links #19

JeepNL opened this issue Nov 12, 2024 · 17 comments · May be fixed by #20
Assignees

Comments

@JeepNL
Copy link

JeepNL commented Nov 12, 2024

Hi there,

I started using X.Bluesky yesterday, and I find it really easy to use - thank you for that!

However, I've noticed some unusual behavior with links to websites (https://) and other Bluesky users (the '@' links):

a) The '@' link itself works, which is great! :)

b) However, the link representation seems off; specifically, the 'blue clickable area' is inconsistent.

See the screenshot below:

In the screenshot, the 'via ' text (including the space, total 4 characters) is blue, but the last four characters of the actual link are white.

Screenshot 2024-11-12 130411

I used the following code:

await client.Post($"Read this post!", new Uri("https://yourlink.com/post/123"));

I believe I've observed similar behavior with an 'https://' link as well when I use

await client.Post($"Read this post from: https://yourlink.com/post/123");

Lastly, maybe it's an idea to add an optional language variable, as I've developed a Dutch news bot, which posts the texts in Dutch.

Thank you for your attention!

@a-gubskiy a-gubskiy self-assigned this Nov 14, 2024
@a-gubskiy a-gubskiy linked a pull request Nov 14, 2024 that will close this issue
@a-gubskiy a-gubskiy linked a pull request Nov 14, 2024 that will close this issue
@a-gubskiy
Copy link
Owner

@JeepNL thank you for report!

Please check this version of package: https://www.nuget.org/packages/X.Bluesky/1.1.3-beta

@JeepNL
Copy link
Author

JeepNL commented Nov 15, 2024

Thank you for your reply and Nuget package update! I've updated the Nuget package and my code, I'm running a .NET/C# console worker service on my Ubuntu VPS which publishes new posts to Bluesky (so it's a news bot).

@a-gubskiy
Copy link
Owner

@JeepNL, I would very much appreciate your feedback on the new version!

@JeepNL
Copy link
Author

JeepNL commented Nov 16, 2024

The previously reported 'link issue' has been resolved.

New Issue: Rate Limiting

I'm encountering what appears to be a rate limiting issue with my worker bot service:

After approximately 22 hours of runtime, the service encounters:

System.Net.Http.HttpRequestException: Response status code does not indicate success: 429 (Too Many Requests).

The new beta version shows different behavior: it now displays [570B blob data] messages instead of the Too Many Requests message.

then after 2-3 hours, normal posting functionality resumes

My service posts approximately 50 to 100 posts per day maximum, this is well within Bluesky's documented rate limits.

I haven't had the opportunity to thoroughly debug this issue yet. While it appears to be related to Bluesky's rate limiting, I'm not certain given my posting volume is below the documented limits.

Also: currently, X.Bluesky creates a new HttpClient instance for the OG parameters fetch (Title, Description, Image). This could potentially be optimized by reusing an existing HttpClient instance. I have to look in this as well.

Screenshot 2024-11-16 140316

@a-gubskiy
Copy link
Owner

Hi!

Regarding HttpClient — I use HttpClientFactory, so it should care about reusing existing instance of http client. I hope on it :)

Regarding rate limit — sometimes library made additional calls internally (for example for resolving identifier of mentioned users). But I am not sure that you use mentions so often. Need to have more details.

@a-gubskiy
Copy link
Owner

@JeepNL I published a new version: https://www.nuget.org/packages/X.Bluesky/1.1.4-beta.

In this version, I added the option to not create a new session every time for each post, and I think it will reduce API calls almost twice.

Please try to use the client with reuseSession: true argument. Please remember that the BlueskyClient instance should be reused in this case.

 public BlueskyClient(string identifier, string password, bool reuseSession, ILogger<BlueskyClient> logger)
        : this(new BlueskyHttpClientFactory(), identifier, password, ["en", "en-US"], reuseSession, logger)
    {
    }

@cultpodcasts
Copy link

cultpodcasts commented Nov 17, 2024

@JeepNL I published a new version: https://www.nuget.org/packages/X.Bluesky/1.1.4-beta.

If I use 1.1.4-beta I get this when I try to run an application that uses this package:

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'X.Bluesky, Version=1.1.4.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'X.Bluesky, Version=1.1.4.0, Culture=neutral, PublicKeyToken=null'
   at XXXXX.Bluesky.Extensions.ServiceCollectionExtensions.AddBlueskyServices(IServiceCollection services, IConfiguration config)
   at Program.<Main>$(String[] args) in C:\Users\jonbr\source\repos\XXXXX\Console-Apps\Poster\Program.cs:line 29
   at Program.<Main>(String[] args)

I do not get this with 1.1.3-beta

Really appreciate your work btw!

@a-gubskiy
Copy link
Owner

What version of .NET do you use?

@cultpodcasts
Copy link

cultpodcasts commented Nov 17, 2024

What version of .NET do you use?

I am using .Net 8 for the class-library and console-app/functions that use this package. I have bumped my deps to v9.0.0 for Microsoft.Extensions.*

I am currently using .Net8 as my main use-case is executing from an Azure Function

@a-gubskiy
Copy link
Owner

I will try to reproduce problem and fix it

@cultpodcasts
Copy link

Please check this version of package: https://www.nuget.org/packages/X.Bluesky/1.1.3-beta

This resolves the issue for me of a corrupted post (repeated the same post content as one that was corrupted when posted) and it works brilliantly. Thank you for your work! I suspect your package is going to be used a lot more and I will certainly recommend it.

@JeepNL
Copy link
Author

JeepNL commented Nov 17, 2024

@a-gubskiy I've installed 1.1.4-beta, and this is the code I'm now using:

BlueskyHttpClientFactory blueskyHttpClientFactory = new();
string[] languages = { "nl", "nl-NL" };
ILogger<BlueskyClient> blueskyLogger = _loggerFactory.CreateLogger<BlueskyClient>();
IBlueskyClient blueskyClient = new BlueskyClient(httpClientFactory: blueskyHttpClientFactory, identifier: blueskyKey, password: blueskyToken, languages: languages, reuseSession: true, logger: blueskyLogger);

It works, and this is the logger output on my Ubuntu VPS

Screenshot 2024-11-17 170410

This news bot publishes to Mastodon & Bluesky

This is an example of a post @ Bluesky, posted with 1.1.4-beta: https://bsky.app/profile/nieuwsjunkies.nl/post/3lb5rgzqjcc2o

@a-gubskiy
Copy link
Owner

@JeepNL So the problem was solved?

@JeepNL
Copy link
Author

JeepNL commented Nov 17, 2024

I don't know yet, because the service is running just for a few minutes., and in the weekend there are fewer news articles (posts), but I'll know more Monday or Tuesday evening, because the worker service is running 24/7. But I think everything looks good, and it should fix the problem. I'll let you know what happens, thank you so much for your help and the new updates!

@a-gubskiy
Copy link
Owner

Got it, so let's keep in touch!

@JeepNL
Copy link
Author

JeepNL commented Nov 17, 2024

Yes, I'll certainly let you know what happens, also if it just works, without any errors!

@a-gubskiy
Copy link
Owner

@cultpodcasts could you please check https://www.nuget.org/packages/X.Bluesky/1.1.5-beta and if there are still issue for you - then please create new issue.

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

Successfully merging a pull request may close this issue.

3 participants