Discussion of article "Websockets for MetaTrader 5"

 

New article Websockets for MetaTrader 5 has been published:

Before the introduction of the network functionality provided with the updated MQL5 API, MetaTrader programs have been limited in their ability to connect and interface with websocket based services. But of course this has all changed, in this article we will explore the implementation of a websocket library in pure MQL5. A brief description of the websocket protocol will be given along with a step by step guide on how to use the resulting library.

Here is a video of the program running whilst connected to the server.


Author: Francis Dube

 
Excellent article. It's about time that MT5 has native websocket support.
Hopefully this code will be included as MT5 standard include files.
Or even better, MT5 shall provide native websocket API for performance reason.

Thank you for your effort.
 
"The release folder contains prebuilt dll and .exe files available for immediate use."

Did you forget that mentioned Release folder on your github page? ;)

 
MetaQuotes:

The article WebSocket for MetaTrader 5 has been published:

Author: Francis Dube

WebSocket even in normal, fast and correct implementations is quite a capricious thing. It is contraindicated to make it in MQL

imho: either it should appear from terminal developers or be provided by external DLLs

 
Why is it needed? Why do you need Websocket and what functionality does it improve over regular mt. Can you give an example of quantitative or qualitative improvement. It was like this, with Websocket it's like this. So many times faster. Thank you!
 

Did you test it on external public servers, especially with TLS? Would be great to see an example(s).

PS. I'm asking because your test doesn't work with wss://echo.websocket.org (I'm attaching the log, BTW - why do you write so bulky useless info?). Pure ws (port 80) works ok. In past I also tried to run my implementation of WebSockets in MQL5, but failed because MQL's sockets have some intricacies with TLS layer. They seem still not solved. And wss is a must nowadays, because all production servers use TLS and decline non-secured connections.

Files:
log.txt  1113 kb
 
Maxim Kuznetsov:

WebSocket even in normal, fast and correct implementations is a rather capricious thing. It should not be done in MQL

imho: either it should appear from the terminal developers or be provided by external DLLs.

What nonsense.

Everything works perfectly well in MQL5.
 
Renat Fatkhullin:
That's rubbish.

Everything works perfectly in MQL5.

It's not nonsense about MQL at all. There were problems with TLS (I wrote about them on the forum, but I did not wait for a solution) and still are. The example from the article does not work. I attached the log to the original English article.

Discussion of article "Websockets for MetaTrader 5"
Discussion of article "Websockets for MetaTrader 5"
  • 2020.11.25
  • www.mql5.com
New article Websockets for MetaTrader 5 has been published: Author: Francis Dube...
 
Renat Fatkhullin:
That's rubbish.

Everything works perfectly in MQL5.

There is an old wss problem there: in the standard function SocketIsReadable ()
It is elementary to bypass, but without this function.

uint len = 1024; //SocketIsReadable(socket);


 
Roman:

There's an old wss problem there: in the standard function SocketIsReadable ()
Workaround is elementary, but already without this function.

Is there any justification for this? What is the magic number and why would it be fine for a message of length 256 or 1500, for example?

 
Roman:

There is an old wss problem there: in the standard function SocketIsReadable ()
Workaround is elementary, but already without this function

You simply do not understand and do not know how to use this function.

This function instantly gives the available number of bytes in the input buffer and does not tell you that the socket is alive. The function is very important and allows you not to go into synchronous waiting, but to read out data portion by portion without losing control over the programme.

And TLS functions are also correct - they are given for trained users who know how and in what sequence to use them. They are not for those who "called and that's it".


Not only that, socket and tls functions are in pure form the same that terminal uses for raw/tls/https connections. That is, everything works fine. These same implementations work in our high load solutions.

Raw network functions are not for beginners and not for naive use. One should understand the principles and peculiarities of network interaction well enough. And if we are talking about TLS, then methods and sequence of processing handshake process.