Wednesday, 09 November 2022
  10 Replies
  460 Visits
  Subscribe
Hello.
I'm trying to connect and send data to a socket.io server but I'm having trouble. I can connect and send data with postman, but in Delphi it just doesn't work.
I can connect but when I send the data, it disconnects.
Any tips?

Thanks in advance.

Here is the code I use

var
WSClient: TsgcWebSocketClient;
socket_io: TsgcWSAPI_SocketIO;

begin
WSClient := TsgcWebSocketClient.Create(self);
socket_io := TsgcWSAPI_SocketIO.Create(self);

socket_io.SOCKETIO.API := ioAPI4;
socket_io.Client := WSClient;

WSClient.Host := 'xxxx'; //here goes the real host name
WSClient.Port := 443;
WSClient.Specifications.RFC6455 := True;
WSClient.TLS := True;
if WSClient.Connect() then
begin
Memo1.lines.add('connect true')
end
else
Memo1.lines.add('connect false');
WSClient.WriteData('42{"new message": "123"}');