В настоящее время я размещаю MetaTrader 4 на Linux-сервере, где торговый бот MetaTrader 4 выполняет веб-запросы.
Один и тот же бот отлично работает в моей собственной системе и в системе моих друзей. Но на сервере он ничего не получает из веб-запросов.
(
)Среда Информация:
- Ubuntu Linux
- Сервер от Contabo Servers
< li>MT4 работает через Wine на Linux
- Я включил все параметры веб-запроса в Metatrader 4.
- Я пытался разблокировать порт 443 с помощью ufw, но ничего из этого не получил.
- br />Тоже попробовал эти статьи
https://www.malibal.com/guides/how-to-o ... on-ubuntu/# :~:text=Для%20example%2C%20если%20вам%20хотите,нужно%20to%20open%20port%2022 - https://linuxconfig.org/how-to-open -allow-incoming-firewall-port-on-ubuntu-22-04-jammy-jellyfish
https://contabo.com/blog/how-to-setup-a ... -in-linux- and-windows/ - https://www.malibal.com/guides/how-to-o ... example%2C %20если%20вы%20хотите,нужно%20to%20откройте%20порт%2022
Ниже приведен код веб-запроса, который отлично работает на всех моих личных системах, но, к сожалению, не работает на серверах Contabo:
Код: Выделить всё
int InternetGetFile(string url,string &content)
{
//--- Init
content=NULL;
//--- Create connection
int httpconnect=0;
int httprequest=0;
int httpopen=Wininet::InternetOpenW("InternetGetFileMQL",0," "," ",0);
int e=kernel32::GetLastError();
if(e==0)
{
bool flag=Wininet::DeleteUrlCacheEntryW(url);
httprequest=Wininet::InternetOpenUrlW(httpopen,url,NULL,0,16|10,0);
e=kernel32::GetLastError();
if(e==0)
{
//--- Define buffers
uchar ch[512];
string temp="";
//--- Retrieve data from file
int cnt=0;
while(Wininet::InternetReadFile(httprequest,ch,512,cnt))
{
//e=kernel32::GetLastError();
if(cnt0)
InternetCloseHandle(httprequest);
if(httpopen>0)
InternetCloseHandle(httpopen);
//--- Get out and return error code
return(e);
}
I found something interesting that may help:
I replaced the previous code and tried to use the inbuilt mql4 web request function
Код: Выделить всё
//--- Call WebRequest function
string method = "GET";
string headers = "";
int timeout = 5000; // Timeout in milliseconds (adjust as needed)
char data[]; // No data to send
char result[4096]; // Fixed-size array to hold response (adjust as needed)
string result_headers;
int request = WebRequest(method, url, headers, timeout, data, result, result_headers);
// Check for successful request
if (request == 200) {
// Copy result to content string
content = CharArrayToString(result);
Print("Data collected");
} else {
// Handle error (you may want to add more error handling)
Print("Error: Web request failed with code ", request);
}
return request;
enter image description here
and funny thing is i added these URLs in the experts tab of the mt4
enter image description here
Источник: https://stackoverflow.com/questions/781 ... nux-server
Мобильная версия