-
Notifications
You must be signed in to change notification settings - Fork 56
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
IPC timeout #15
Comments
In fact, let's get rid of any complexity.
Either the same will happen or instead this error:
|
same here |
Here's an update for anyone interested: I've managed to get this working starting from within the docker image as @luismasuelli tried. Then tried the same thing on the host and it worked too. What's the trick? You have to first login into an account once from the meta trader UI. Then the For me this was a problem, since I needed the whole thing to be fully automated and headless. I've came up with a temporary solution which is to use puppeteer to automate the first login process. Here's how I did: import puppeteer from "puppeteer-core";
import { sleep } from "./utils";
(async () => {
// Launch the browser and open a new blank page
const browser = await puppeteer.launch({
channel: "chrome",
headless: false, // switch this to true to enable chrome headless mode
});
const page = await browser.newPage();
// Set screen size.
await page.setViewport({ width: 1920, height: 1080 });
// Navigate the page to the vnc web page
await page.goto("http://localhost:3000");
// Give it a couple of seconds to render and stabilize
await sleep(2);
// Close any open menus
page.keyboard.press("Escape");
await sleep(0.3);
// Open "File" menu
page.keyboard.down("Meta");
page.keyboard.up("Meta");
page.keyboard.down("Alt");
page.keyboard.down("F");
await sleep(0.3);
page.keyboard.up("Alt");
page.keyboard.up("F");
await sleep(0.3);
// Open "Login to trade account" sub menu
page.keyboard.press("L");
await sleep(2);
page.keyboard.press("Enter");
console.log("Should have now been logged");
await sleep(5);
await browser.close();
})(); I used Check out puppeteer's documentation for more information and stuff you can do with it. It's super powerful. Unfortunately most of the cool things requires interaction with DOM elements, while kamsvnc renders the DOM within an iframe and then displays everything with a canvas element. However the keyboard interactions seems to work, which for the scope of this problem was all that I needed. Of course to make this production ready, stable and scalable it needs more work, but it can be a somewhat decent starting point. The idea came to mind after learning about a python library called So I thought that maybe a keyboard keypress might be intercepted if automated via a tool like puppeteer. Hope this helps someone |
Did you manage it to run it in your Docker container? Do you have full steps there?
…________________________________
De: Caius Citiriga ***@***.***>
Enviado: sábado, 30 de noviembre de 2024 10:07
Para: gmag11/MetaTrader5-Docker-Image ***@***.***>
Cc: luismasuelli ***@***.***>; Mention ***@***.***>
Asunto: Re: [gmag11/MetaTrader5-Docker-Image] IPC timeout (Issue #15)
Here's an update for anyone interested:
I've managed to get this working starting from within the docker image as @luismasuelli<https://github.com/luismasuelli> tried. What's the trick?
You have to first login into an account once from the meta trader UI. Then the initialize and other commands will start to work from the mt5linux bridge library.
For me this was a problem, since I needed the whole thing to be fully automated and headless.
I've came up with a temporary solution which is to use puppeteer to automate the first login process, here's how I did:
import puppeteer from "puppeteer-core";
import { sleep } from "./utils";
(async () => {
// Launch the browser and open a new blank page
const browser = await puppeteer.launch({
channel: "chrome",
headless: false,
});
const page = await browser.newPage();
// Set screen size.
await page.setViewport({ width: 1920, height: 1080 });
// Navigate the page to the vnc web page
await page.goto("http://localhost:3000");
// Give it a couple of seconds to render and stabilize
await sleep(2);
// Close any open menus
page.keyboard.press("Escape");
await sleep(0.3);
// Open "File" menu
page.keyboard.down("Meta");
page.keyboard.up("Meta");
page.keyboard.down("Alt");
page.keyboard.down("F");
await sleep(0.3);
page.keyboard.up("Alt");
page.keyboard.up("F");
await sleep(0.3);
// Open "Login to trade account" sub menu
page.keyboard.press("L");
await sleep(2);
page.keyboard.press("Enter");
console.log("Should have now been logged");
await sleep(5);
await browser.close();
})();
Of course to make this production ready, stable and scalable it needs more work, but it can be a somewhat decent starting point. The idea came to mind after learning about a python library called vncdotool, but this library only worked with a vnc client, but kamsvnc is 100% web and requires no vnc client installed.
So I thought that maybe a keyboard keypress might be intercepted if automated via a tool like puppeteer.
Hope this helps someone
—
Reply to this email directly, view it on GitHub<#15 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AANZHHD55CTKAMI463DM4PL2DHIE7AVCNFSM6AAAAABQEWRDXKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMBYHE4TCMBZGE>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@luismasuelli I'll come out with an example soon, so you can give it a try 😊 |
Steps to reproduce:
my-compose-file.yml
):This is the code I try in Python (in my host machine).
Result:
mt5.initialize()
returnsFalse
after a long time, and nothing is initialized.mt5.last_error()
returns(-10005, "IPC timeout")
.mt5.version()
returns an empty result.I expect:
Everything to work fine.
The text was updated successfully, but these errors were encountered: