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

[error] Failed to initialize session. #4

Open
whakru opened this issue Feb 26, 2025 · 1 comment
Open

[error] Failed to initialize session. #4

whakru opened this issue Feb 26, 2025 · 1 comment

Comments

@whakru
Copy link

whakru commented Feb 26, 2025

When I try to use it, I get:

[[ip][login]][debug] POST /login
[[ip][login]][error] Failed to initialize session
import { Panel } from "3x-ui";
const uripanel = `https://login:pass@ip:port/baseurl/`;
const panel = new Panel(uripanel)
panel.debug = true; 
panel.stdTTL = 0;
console.log(await panel.getInbounds())

but another project on the same server uses the same library and everything works fine.
Are there any restrictions that I'm trying to connect to the same server from different projects on the same PC?
could there be some kind of conflict?

@whakru
Copy link
Author

whakru commented Feb 26, 2025

I decided to simulate your code like this:

const data = {
    username: 'login',
    password: 'pass'
};

const sendPostRequest = async () => {
    try {
        const response = await axios.post('https://ip:port/base/login', data, {
            headers: {
                'Content-Type': 'application/json'
            }
        });
        const { status, data: responseData } = response;

        console.log(`: ${status}`);
        console.log(':', responseData);
    } catch (error) {
        console.error(':', error.message);
    }
};

and I immediately got an error: self-signed certificate

Then everything fell into place)
I needed to use process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';

It might be worth making a variable to enable SSL ignoring)

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

No branches or pull requests

1 participant