客户端如何连接到 MQL 中的服务器套接字?
我想将超过 50000 个客户端连接到 MQL(Meta Trader)服务器套接字。 文档中没有对此进行描述: https://www.mql5.com/ en/docs/network/socketcreate
有多少客户端可以连接到服务器并且处理没有问题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
答:
确实不是一件容易的事。
您可能已经知道,所有 MetaTrader 4/5 生态系统都是作为分布式系统构建的,具有终端端(在您的客户端端)和服务器 端(一个多主机平台,位于经纪商数据中心,负责注册用户、验证和馈送,除了许多其他值得注意的事情之外,还有一个对延迟敏感的高容量(市场容量乘以数量)活跃客户)流{ CFD | FX | * }-市场
QUOTE
消息(在 FX 市场上每毫秒轻松出现数百个 ToB 事件/消息)至所有已授权的活动 { MT4 | 终端计算机接受并执行来自授权客户端的 XTO 指令并报告结果(已执行的状态更改)客户资金会计操作)从 XTO-s 返回到相应交易者的终端)。在经纪商方面,这些工作量被分配给多台 MetaTrader 4/5 Server 服务器基础设施计算机。 Web 套接字处理由此类代理端基础设施的一部分提供服务。MetaTrader 4/5 终端离您更近了,您可以在其中进行编程和操作。控制。即使在这里,资源量也是有限的,因为您可以从链接的终端端而不是可用编程工具的服务器端文档中读取:
因此,Server 端由 Broker 控制(谁拥有使用 MetaQuotes, Inc. 产品的许可证,该产品已针对预期性能范围进行配置 - 是否准备好处理额外的 50.000 个 Web 套接字连接对于 NTO-s 可能不是经纪商的核心业务优先事项,因为他们向 XTO-s 收取费用)
-&-
鉴于您将 MT5 客户端终端称为某种意义上的“服务器”(只是一个 VPS 托管的 MT5 客户端终端,运行用户定义的 MQL5-ExpertAdviser 代码),似乎有一些魔力:
(A)
您声称能够“(...) 毫无问题地接受 500 个客户端。”,这与 MQL5 官方记录的从客户端打开的套接字不超过 128 个套接字的限制直接矛盾MQL5-{ EA | 脚本 }-code
脚本 }-代码(B)
官方 MQL5 文档没有提供 MT5 客户端终端如何运行 MQL5-{ EA | (B)
脚本 }-代码可以接收从远程客户端异步到达的连接(但没有指定这种情况如何发生,因为官方 MQL5 文档严格要求在 2022 年第一季度使用 MQL5 语言函数时实际上要避免这种情况发生)
< strong>(C)
官方 MQL5 文档确认,可以从 MT5 客户端终端内部进行
SocketConnect()
MQL5-{ EA |将 }-code 编写到已知的 TCP/IP:PORT 地址:肯定可以使用其他一些 DLL-
#import
-ed 工具来完成类似的任务,但没有 MCVE 制定的问题描述到目前为止,除了上面已经描述的事实之外,很难透露更多内容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 :
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 )
-&-
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 :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有一篇文章解释了如何在 MT5 上创建服务器:
在 MQL 中使用套接字,或如何成为信号提供者
https://www.mql5.com/en/articles/2599
There is an article explaining how to create a server on MT5:
Working with sockets in MQL, or How to become a signal provider
https://www.mql5.com/en/articles/2599
您可以通过 mql 客户端的 API 使用 webrequest 方法
You can using webrequest method with API from mql client