Skip to content

[suggestion] multiple connections #277

@GabrieleRisso

Description

@GabrieleRisso

Hello, thanks for the exellent api. I am using every feature of the api (version 5.2) and face swap consistently without issues. In my codebase I am running multiple istances of the same program using cluster workers and I have the feeling some of those istances are having toruble to conenct, resulting in a failure.
I was wandering if you could suggest a better way of implementing the connection setup or config parameters to tune it in order to have 16 parallel connections.
here is my current implementation:

import { ImIDnfigParam, Midjourney } from "midjourney";

const ImIDnfig: ImIDnfigParam = {
SalaiToken: process.env.SALAI_TOKEN,
ChannelId: process.env.CHANNEL_ID,
ServerId: process.env.SERVER_ID,
HuggingFaceToken: "hf_XXXXXXXXXXXXXXXXXXXXXX",
//Debug: true,
Ws: true,
//Limit: 200
};

const midclient = new Midjourney(ImIDnfig);

await midclient
.init()
.then(() => {
console.log("[OK] MidClient initialized successfully.");
})
.catch((error) => {
console.error("[XX] Failed to initialize MidClient:", error);
});

const msg = await midclient
.Imagine(${prompt} --quality ${quality}, (uri: string, progress: string) => {
console.log("Imagine.loading", uri, "progress", progress);
})
.catch((error) => {
console.error("Error in midclient.Imagine:", error);
throw error; // Rethrow the error to propagate it further
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions