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? ;)

 

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
 
Did you manage to connect via WSS?
 

Nice work @Francis Dube, Thanks!

Is it possible to create a MQL5 service that acts as the WebSocket server? Do you have some examples?

 

Hey great work, 

I just tested your ea and it did connect to my C# websocket server, however after it connects and sends the message The journal tab spans this error

2022.02.08 07:33:36.176 Websocketclient_test (XAUUSD,M15) [MQL error ID: 5270][Is Socket Readable ][Line: 238][Function: CSocket::Readable]


any idea how I can get this fixed. Also sending back to Mt4 didn't seem to work

 

@Francis Dube Thank you for this library. There is a small change I had to make for it to work with URLs after /, e.g. /ws/..

However I find that it is not stable and doesn't always work, where as your WinAPI version works lot better.

As this one is a native library, do you have an improved version with the stability issues fixed?

Thank you

Reason: