Websocket connection

 

Hi!

I have started building out a tradingview signal system similar to PineConnector using Flask, nginx and managed to make it work perfectly by using http polling. After this i wanted to make some enchantments and add socket connection and keep http as a backup. I started out building and testing it on MT5 Build number 4620 and everything worked perfectly but after upgrading the MT5 to build 4735 all the suddent the socket connection broke and started getting "TLS handshake failed: 5274". Now i dont know what changed in 4735 cause there isn't a changelog for it so i am clueless. Tried a bunch of setting with nginx protocols and ciphers but nothing worked just kept getting  SSL_read() failed (SSL: error:0A0001BB:SSL routines::bad record type) while waiting for request.


Below is the code that runes into this issue, socket and host are all set. As i said this was working perfectly untill the update.

bool InitializeTLS()
    {
        Print("Starting TLS handshake");
        if(!SocketTlsHandshake(socket, host))
        {
            Print("TLS handshake failed: ", GetLastError());
            return false;
        }
        
        // Verify certificate
        string subject, issuer, serial, thumbprint;
        datetime expiration;
        if(!SocketTlsCertificate(socket, subject, issuer, serial, thumbprint, expiration))
        {
            Print("Failed to verify TLS certificate: ", GetLastError());
            return false;
        }
        
        Print("TLS connection established");
        Print("Certificate: ", subject);
        return true;
    }


Some help would be much appreaciated to shed some light on this.

If any more code is needed for further debugging just ask and i will add it.


Thanks!

 
SocketTlsHandshake() is not needed if port is 443 (standard/default secure port).
 
Soewono Effendi #:
SocketTlsHandshake() is not needed if port is 443 (standard/default secure port).

Huge Thanks! Been on it for 2 days. It's working now.