Coder Social home page Coder Social logo

Comments (12)

LordTylus avatar LordTylus commented on June 6, 2024

Additional information:

Sometimes just posting an Image Link also doesnt seem to be rendered:
image

Posted it twice, the first one was not rendered, all subsequent ones were without problem.

from discord-api-docs.

LordTylus avatar LordTylus commented on June 6, 2024

Additional Information:

Uploading the Image and referencing it in the Embed works fine every time. So the problem seems to be related to external links. I really don't want to upload a bunch of files to discord when it is not needed, since everything is already online on the respective website.

from discord-api-docs.

sklein12 avatar sklein12 commented on June 6, 2024

@LordTylus are you able to reproduce this with all external hosted images or just ones hosted on www.twinsdragonscomic.com?

from discord-api-docs.

LordTylus avatar LordTylus commented on June 6, 2024

@sklein12 certainly not on all.

I can consistently reproduce it with twindragonscomic.com and savestatecomic.com

Both seem to run on WordPress. The owners are independent and they have independent servers as well.

I tested it with image links that point to Tumblr's cdn and those work just fine. And image links pointing to DeviantArt also seem to work without issue.

These WordPress pages aren't the quickest to respond. And if they work it takes a few good seconds till the image appears in the embed. While the links to Tumblr or DeviantArt appear near instantly.

Could there be a timeout involved?

I have seen images. Not loading occasionally in the past. Maybe once a month. So I never gsve it mich thought. That it is this bad only happens for about a week.

When I upload the images as file attachments to discord and reference the attachment in the embed it works fine too. So I am starting to believe that it might be related to WordPress. But sadly I don't have any way of analyzing what's happening.

from discord-api-docs.

yonilerner avatar yonilerner commented on June 6, 2024

A quick scan of the code indicates that we'd timeout after 5 seconds. In my playing around right now, the images load pretty instantly and are unfurling very consistently. Its possible that when this site is under load it fails to respond within 5 seconds and we give up

from discord-api-docs.

LordTylus avatar LordTylus commented on June 6, 2024

This is rather odd.

When it works I never had to wait 5 seconds. It took a like maybe 1 to 2 seconds. When I download the picture first via OkHttpClient and upload it, its also always like 1 second. (Gut feeling I never measured it)

Opening an image in browser without cache also seems to be rather quick. I can run additional tests tonight, where I take more exact time measurements. And not just gut feeling.

Plan is I download a picture via OkHttpClient 20 times to see what the min avg and max load times are. And I Link to it via discord embed and see how many of those fail. Alternatively I load ans post 20 different pictures.

I mean of course there are other things that could ve at play here. Latency potentially depending on where the servers are physically located and where its being connected from.

from discord-api-docs.

LordTylus avatar LordTylus commented on June 6, 2024

Hello there again,

sorry for the long wait. But I have conducted a few more tests:
First I attempted to send the same picture 20 Times with little to no delay in between.
The result was, that out of the 20 times. 5 were successful 15 failed.

image
image

Running the test again resulted in 20 pictures not being displayed. Probably some spam detection going on? Not sure...
image

Then I added some delay of 2 seconds between sending an embed with the same picture. Those were 20 successful ones.
image

And then I grabbed 20 random Image URLs from my archive measured the times and output:

        try {

            List<String> urls = List.of(
                    "https://www.twindragonscomic.com/wp-content/uploads/2019/11/Twin_Dragons_221.png",
                    "https://www.twindragonscomic.com/wp-content/uploads/2019/06/Twin_Dragons_201.png",
                    "https://www.twindragonscomic.com/wp-content/uploads/2022/11/Twin_Dragons_368.png",
                    "https://www.twindragonscomic.com/wp-content/uploads/2016/04/Twin_Dragons_035.png",
                    "https://www.twindragonscomic.com/wp-content/uploads/2023/10/Twin_Dragons_419.png",
                    "https://www.twindragonscomic.com/wp-content/uploads/2020/09/Twin_Dragons_267.png",
                    "https://www.twindragonscomic.com/wp-content/uploads/2016/04/Twin_Dragons_036.png",
                    "https://www.twindragonscomic.com/wp-content/uploads/2020/04/Twin_Dragons_245.png",
                    "https://www.twindragonscomic.com/wp-content/uploads/2017/09/Twin_Dragons_108.png",
                    "https://www.twindragonscomic.com/wp-content/uploads/2022/09/Twin_Dragons_362.png",
                    "https://www.twindragonscomic.com/wp-content/uploads/2018/12/Twin_Dragons_174.png",
                    "https://www.twindragonscomic.com/wp-content/uploads/2020/06/Twin_Dragons_253.png",
                    "https://www.twindragonscomic.com/wp-content/uploads/2018/01/Twin_Dragons_123.png",
                    "https://www.twindragonscomic.com/wp-content/uploads/2024/03/Twin_Dragons_437.png",
                    "https://www.twindragonscomic.com/wp-content/uploads/2016/01/Twin_Dragons_022.png",
                    "https://www.twindragonscomic.com/wp-content/uploads/2022/09/Twin_Dragons_359.png",
                    "https://www.twindragonscomic.com/wp-content/uploads/2017/12/Twin_Dragons_121.png",
                    "https://www.twindragonscomic.com/wp-content/uploads/2023/03/Twin_Dragons_388.png",
                    "https://www.twindragonscomic.com/wp-content/uploads/2018/09/Twin_Dragons_160.png",
                    "https://www.twindragonscomic.com/wp-content/uploads/2016/10/Twin_Dragons_061.png"
            );

            OkHttpClient okHttpClient = new OkHttpClient();

            int i = 0;

            for (String url : urls) {

                Thread.sleep(2000);

                long start = System.currentTimeMillis();

                Request request = new Builder().url(url).build();

                try (Response response = okHttpClient.newCall(request).execute()) {

                    ResponseBody body = response.body();
                    if (body != null)
                        log.info("{} - loaded {} bytes in {} ms", i, body.bytes().length, System.currentTimeMillis() - start);
                }

                TextChannel textChannelById = guild.getTextChannelById(1082027410683338852L);

                MessageEmbed embed = new EmbedBuilder()
                        .setTitle(i + " Title")
                        .setAuthor("Me")
                        .setImage(url)
                        .setDescription("This is a Test")
                        .build();

                textChannelById.sendMessageEmbeds(embed).queue();

                i++;
            }

        } catch (IOException e) {
            log.error("Error", e);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

The following Result was output:

17:29:50,522 [INFO ] [JDA MainWS-ReadThread] [DebugModule] 0 - loaded 617369 bytes in 1364 ms
17:29:53,236 [INFO ] [JDA MainWS-ReadThread] [DebugModule] 1 - loaded 670099 bytes in 702 ms
17:29:55,944 [INFO ] [JDA MainWS-ReadThread] [DebugModule] 2 - loaded 698810 bytes in 705 ms
17:29:58,635 [INFO ] [JDA MainWS-ReadThread] [DebugModule] 3 - loaded 585526 bytes in 688 ms
17:30:01,348 [INFO ] [JDA MainWS-ReadThread] [DebugModule] 4 - loaded 662221 bytes in 701 ms
17:30:04,042 [INFO ] [JDA MainWS-ReadThread] [DebugModule] 5 - loaded 608909 bytes in 692 ms
17:30:06,722 [INFO ] [JDA MainWS-ReadThread] [DebugModule] 6 - loaded 499930 bytes in 676 ms
17:30:09,408 [INFO ] [JDA MainWS-ReadThread] [DebugModule] 7 - loaded 505202 bytes in 683 ms
17:30:12,101 [INFO ] [JDA MainWS-ReadThread] [DebugModule] 8 - loaded 549066 bytes in 687 ms
17:30:14,820 [INFO ] [JDA MainWS-ReadThread] [DebugModule] 9 - loaded 684347 bytes in 707 ms
17:30:17,521 [INFO ] [JDA MainWS-ReadThread] [DebugModule] 10 - loaded 639092 bytes in 700 ms
17:30:20,204 [INFO ] [JDA MainWS-ReadThread] [DebugModule] 11 - loaded 527214 bytes in 682 ms
17:30:23,115 [INFO ] [JDA MainWS-ReadThread] [DebugModule] 12 - loaded 550961 bytes in 907 ms
17:30:25,826 [INFO ] [JDA MainWS-ReadThread] [DebugModule] 13 - loaded 644565 bytes in 698 ms
17:30:28,500 [INFO ] [JDA MainWS-ReadThread] [DebugModule] 14 - loaded 475130 bytes in 673 ms
17:30:31,192 [INFO ] [JDA MainWS-ReadThread] [DebugModule] 15 - loaded 576589 bytes in 690 ms
17:30:33,891 [INFO ] [JDA MainWS-ReadThread] [DebugModule] 16 - loaded 617201 bytes in 695 ms
17:30:36,584 [INFO ] [JDA MainWS-ReadThread] [DebugModule] 17 - loaded 560529 bytes in 691 ms
17:30:39,278 [INFO ] [JDA MainWS-ReadThread] [DebugModule] 18 - loaded 598631 bytes in 692 ms
17:30:41,961 [INFO ] [JDA MainWS-ReadThread] [DebugModule] 19 - loaded 498583 bytes in 678 ms

As you can see every image was loaded by my OkHttpClient within ~700ms

However there were a few images that were not loaded:
image
(ignore the 0 Title... I forgot to advance i in my loop -.-

But I could see that the following URLs were not displayed correctly.

                "https://www.twindragonscomic.com/wp-content/uploads/2022/11/Twin_Dragons_368.png",
                "https://www.twindragonscomic.com/wp-content/uploads/2020/09/Twin_Dragons_267.png",
                "https://www.twindragonscomic.com/wp-content/uploads/2016/04/Twin_Dragons_036.png",
                "https://www.twindragonscomic.com/wp-content/uploads/2018/12/Twin_Dragons_174.png",

I then ran the test again.

This time, some of the previous images were displayed correctly. Others, however, were no longer:
image

                "https://www.twindragonscomic.com/wp-content/uploads/2022/11/Twin_Dragons_368.png",
                "https://www.twindragonscomic.com/wp-content/uploads/2016/04/Twin_Dragons_036.png",
                "https://www.twindragonscomic.com/wp-content/uploads/2018/12/Twin_Dragons_174.png",

these failed to load.

I kind of dont believe its a timeout issue, since the server seems to respond to my requests just fine in an acceptable amount of time. Loading the preview however seems to randomly not work.

I hope this helps narrowing the issue down.

from discord-api-docs.

yonilerner avatar yonilerner commented on June 6, 2024

This is incredibly helpful, thank you. We will continue to investigate on our side

from discord-api-docs.

yonilerner avatar yonilerner commented on June 6, 2024

This time, some of the previous images were displayed correctly. Others, however, were no longer:

It sounds like you're saying here that some that previously loaded were no longer loading, but the list of images that didn't load

                "https://www.twindragonscomic.com/wp-content/uploads/2022/11/Twin_Dragons_368.png",
                "https://www.twindragonscomic.com/wp-content/uploads/2016/04/Twin_Dragons_036.png",
                "https://www.twindragonscomic.com/wp-content/uploads/2018/12/Twin_Dragons_174.png",

seems to be a subset of the first set of images that didn't load.

Just want to confirm that there are no images that loaded in the first test of 20 different images that didn't in the 2nd test

from discord-api-docs.

LordTylus avatar LordTylus commented on June 6, 2024

I double checked it just now. You are right I thought it loaded one less, but apparently it didn't.

However, I just ran this test again. And you are right, it could still load all previous images and 1 extra. So now only

                "https://www.twindragonscomic.com/wp-content/uploads/2016/04/Twin_Dragons_036.png",
                "https://www.twindragonscomic.com/wp-content/uploads/2018/12/Twin_Dragons_174.png",

it couldn't load.

I guess Ill have to use a different random set next, if there actually is some caching involved I could imagine after testing a few more times it will have all of them.

from discord-api-docs.

yonilerner avatar yonilerner commented on June 6, 2024

Ya so we cache successes for a day and we cache failures for 5 minutes. So that explains both why you never see things that used to succeed start to fail, and why testing a single image 20 times with no delay after it failed once failed all 20 of them.

As for why its failing to begin with.. unclear still. Our tracing shows that we are indeed timing out when trying to fetch the images, but its not clear why yet.

from discord-api-docs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.