question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

403 on Download of Mongo 4.4.1

See original GitHub issue

Hello 😃 I am using de.flapdoodle.embed.mongo 3.0.0 and here is my code :

    RuntimeConfig runtimeConfig = Defaults
        .runtimeConfigFor(command)
        .artifactStore(Defaults.extractedArtifactStoreFor(command)
            .withDownloadConfig(Defaults.downloadConfigFor(command).build())
            .executableNaming(new UserTempNaming())).build();

    EnumSet<Feature> features = Version.V4_4_1.getFeatures();
    IFeatureAwareVersion iFeatureAwareVersion = Versions.withFeatures(Version.V4_4_1, features);

    ImmutableMongodConfig mongodConfig = ImmutableMongodConfig.builder()
        .version(iFeatureAwareVersion)
        .net(new Net(port, true))
        .build();

    MongodStarter runtime = MongodStarter.getInstance(runtimeConfig);

But I get : Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.4.1.tgz at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1924) at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520) at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:250) at de.flapdoodle.embed.process.store.UrlConnectionDownloader.downloadInputStream(UrlConnectionDownloader.java:130) … 30 more

However, If I switch the version to 4.0.12 for example everything seems fine …

Can you please help ? 😃

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:9
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
robin850commented, Nov 27, 2020

It looks like MongoDB changed all their URL patterns for download (since 4.2 IIUC looking at this page ; and that would explain why it works for you on 4.0.12).

This means that:

  • On macOS, the osx becomes macos only in the archive name (the folder name remains osx).
  • There seems to be no “generic Linux” package after 4.0, only distro-specific ones.
  • The ssl part seem to be removed from packages.
  • The 2008plus part is replaced with 2012plus for Windows archives.
  • Since 3.4, there seems to be no support for 32-bit platforms.

Waiting for a fix, you can try something like:

class CustomPackageResolver extends Paths {
    public CustomPackageResolver(Command command) {
        super(command);
    }

    @Override
    public String getPath(Distribution distribution) {
        return "linux/mongodb-linux-x86_64-ubuntu1804-4.2.0.tgz";
    }
}

And then use it like:

Command command = Command.MongoD;

RuntimeConfig runtimeConfig Defaults.runtimeConfigFor(command)
        .artifactStore(Defaults.extractedArtifactStoreFor(command)
                .withDownloadConfig(Defaults.downloadConfigFor(command)
                        .packageResolver(new CustomPackageResolver(command))
                        .build()))
        .build();

(Here is an attempt to have something that works on all OSes but I’ve only tested it on macOS to be honest.)

Since this project recently bumped to version 3, a lot of versions were deprecated. Maybe, to ease the maintenance, they should be removed because it may be a PITA to provide something that works with older and newer versions.

3reactions
Xaseroncommented, Jan 28, 2021

No only have they changed the filename structure of the zip file. Also they have changed the directory name after extraction in a non coherent fashion.

I’ve already changed this for run-rs https://github.com/vkarpov15/run-rs/blob/master/src/download.js#L57

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - 403 on Download of Mongo 4.4.1 - - Bountysource
Coming soon: A brand new website interface for an even better experience!
Read more >
Error: Status Code is 403 (MongoDB's 404) This means that ...
the error is occurring because the URL link that mongo memory server is creating to download a binary version of mongo is wrong...
Read more >
Try MongoDB Atlas Products
Try MongoDB Atlas products free. Developers can choose to use in the cloud or download locally. Either way, our software makes it easy...
Read more >
How To Install MongoDB on Ubuntu 20.04 - DigitalOcean
[ arch=amd64,arm64 ] : This specifies which architectures the APT data should be downloaded to. In this case, it specifies the amd64 and...
Read more >
Apt-get fails on 16.04 or 18.04 installing mongodb - Ask Ubuntu
Ubuntu 18.04 and MongoDB 4.2. First, remove MongoDB from previous if installed: sudo apt remove --autoremove mongodb-org.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found