I use Delphi websocket to get data from Binance.
uses IdIOHandler, IdIOHandlerSocket, IdIOHandlerStack, IdSSL, IdSSLOpenSSL, IdWebSocketSimpleClient;
type
...
procedure lSWC1DataEvent(Sender: TObject; const Text: string);
private
...
public
...
procedure TForm1.lSWC1DataEvent(Sender: TObject; const Text: string);
begin
Form1.smemo1.Lines.Add(text);
end;
#use these parameters to avoid SSL3_READ_BYTES:sslv3 alert handshake failure
procedure TForm1.Button1Click(Sender: TObject);
var lSWC:TIdSimpleWebSocketClient;
begin
lSWC := TIdSimpleWebSocketClient.Create(self);
lSWC.onDataEvent := lSWC1DataEvent; //:= self.lSWC1DataEvent; //TSWSCDataEvent
lSWC.AutoCreateHandler := false;
if not lSWC.AutoCreateHandler then
begin
if lSWC.IOHandler=nil then
lSWC.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(lSWC);
(lSWC.IOHandler as TIdSSLIOHandlerSocketOpenSSL).SSLOptions.Mode := TIdSSLMode.sslmClient;
(lSWC.IOHandler as TIdSSLIOHandlerSocketOpenSSL).SSLOptions.Method := sslvSSLv23;
(lSWC.IOHandler as TIdSSLIOHandlerSocketOpenSSL).SSLOptions.SSLVersions := [TIdSSLVersion.sslvSSLv23];
end;
lSWC.Connect('wss://stream.binance.com:9443/ws/btcusdt@kline_15m');
(lSWC.IOHandler as TIdSSLIOHandlerSocketOpenSSL).PassThrough:=false;
end;
added this .pas to my Project:
https://github.com/arvanus/Indy/blob/WebSocketImpl/Lib/Core/IdWebSocketSimpleClient.pas