How may client can connect to the server socket in MQL?

How may client can connect to the server socket in MQL?

Manage alerts

Loading saved threads...

Behzad · External communityPost link
External question — Stack Overflow Stack Exchange Author: Behzad Original post: https://stackoverflow.com/questions/71283512 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I want to connect more than 500 hundred client to the MQL (Meta Trader) server socket. There is no description about it in the documentation: https://www.mql5.com/en/docs/network/socketcreate How many client can connect to the sever and deal with no problem?
Quote
Report
user3666197 · External communityPost link
External answer — Stack Overflow Stack Exchange Author: user3666197 Original post: https://stackoverflow.com/a/71284070 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Q : " I want to connect more than 500 hundred client to the MQL (Meta Trader) server ... How many client can connect to the sever and deal with no problem? " A : Not an easy task, indeed. As you may already know, all the MetaTrader 4/5 ecosystems are built as a distributed-system, having a Terminal -side ( on your, clients' side(s) ) and a Server -side ( a multi-host platform, located at the Broker DataCenter, who registers users, authenticates & feeds, besides many further noted things, a latency-sensitive, high-volume ( markets Volume-wise times number of active clients-wise ) stream of { CFD | FX | DeFi | * }-Market QUOTE messages (having easily cadence of hundreds ToB-events / messages per millisecond at FX-market) to all auth'ed active { MT4 | MT5 }- Terminal computers & accepts and executes XTO-instructions from auth'ed clients & reports results ( state-changes preformed & client's-funds accounting operations ) from XTO-s back to the respective trader's terminals ). That amount of work is, on the Broker side, split among several MetaTrader 4/5 Server server-infrastructure computers. The web-socket handling gets served by one part of such Broker-side infrastructure. Closer to your reach goes the MetaTrader 4/5 Terminal , that you can program & control. Even here the amounts of resources are limited, as you can read from your linked, Terminal -side, not Server-side documentation of programming tools available : You can create a maximum of 128 sockets from one MQL5 program. If the limit is exceeded, the error 5271 (ERR_NETSOCKET_TOO_MANY_OPENED) is written to _LastError. So, the Server-side is controlled by the Broker ( who owns the license to use the MetaQuotes, Inc. product, that gets configured for expected performance envelopes - being ready or not to handle additional 50.000 web-socket connections for NTO-s might not be the Brokers' core business priority, as they collect fees from XTO-s ) "(...) The question is, do we create new socket for each client to connect? As I know, we create the server socket just one time on the Oninit function, then on a timer or chart event handler, do accepting incoming client connection request. So, there is just one socket and many client connect to this socket. Am I right @user3666197 ? – Behzad 23 hours ago" -&- "I think my question is not clear. I have done this project. I bought a VPS then install a MT5 on it with the EA that has played the server role. The sever EA could accept 500 client without any problem. It can send and receive messages as well as one connection. For clients, on my pc create a loop to connect 500 connection to the server. One socket on the server EA. – Behzad 4 hours ago" Given you call MT5-Client-Terminal a "server" in a sense ( just a VPS-hosted MT5-Client-Terminal, running a user-defined MQL5-ExpertAdviser-code ), there seems to be some magic : (A) you claim to be able to "(...) accept 500 client without any problem." , which is in a direct contradiction to the official MQL5-documented limit of not more than 128 sockets ever opened from an MQL5-{ EA | Script }-code (B) the official MQL5-documentation does not present a way, how an MT5-Client-Terminal running an MQL5-{ EA | Script }-code can receive connections arriving asynchronously from remote clients ( yet without specifying how that might ever happen, as the official MQL5-Documentation is strict on practically avoiding such to happen if using the MQL5-language functions as of 2022-Q1 ) (C) the official MQL5-documentation confirms, one can SocketConnect() from inside an MT5-Client-Terminal MQL5-{ EA | Script }-code to a known TCP/IP:PORT address : string KNOWN_ADDRESS = "some.known.FQDN"; int KWOWN_PORT = 80, TimeoutMILLIS = 1000; bool FLAG_ExtTLS = false; //+------------------------------------------------------------------+ ... int MyOUTGOINGsocket = SocketCreate(); //--- check the handle if ( MyOUTGOINGsocket != INVALID_HANDLE ) { if ( SocketConnect( MyOUTGOINGsocket, //--- from MT5-Terminal KNOWN_ADDRESS, // to <_address_> KNOWN_PORT, // on <_port_> TimeoutMILLIS // try <_millis_> ) // else FAIL ) { Print( "INF: Established connection to ", KNOWN_ADDRESS, ":", KNOWN_PORT ); ... } else { Print( "ERR: Connection to ", KNOWN_ADDRESS, ":", KNOWN_PORT, " failed, error ", GetLastError() ); ... } SocketClose( MyOUTGOINGsocket ); //--- close a socket to release RAM/resources } else { Print( "ERR: Failed to even create a socket, error was ", GetLastError() ); ... } ... ... //+------------------------------------------------------------------+ One may use, for sure some other, DLL- #import -ed tools for the similar tasks, yet as no MCVE-formulated problem description was presented so far, it is so hard to tell anything more, except for the facts already described above
Quote
Report
GoldStreet VN · External communityPost link
External answer — Stack Overflow Stack Exchange Author: GoldStreet VN Original post: https://stackoverflow.com/a/73314348 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. You can using webrequest method with API from mql client
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: Behzad Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/questions/71283512 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I want to connect more than 500 hundred client to the MQL (Meta Trader) server socket. There is no description about it in the documentation: https://www.mql5.com/en/docs/network/socketcreate How many client can connect to the sever and deal with no problem?

Cancel quote

Checking account access…