You are not logged in.
Pages: 1
I'm trying to get up and running with a simple Websocket client example.
I would like to connect to the test echo websocket server @
wss://echo.websocket.org
(info at https://www.websocket.org/echo.html)
My code looks like this:
...
fWebSockets: THttpClientWebSockets;
proto: TWebSocketProtocolChat;
procedure OnFrameReceived(Sender: THttpServerResp;
const Frame: TWebSocketFrame);
...
procedure TForm1.btnConnect2Click(Sender: TObject);
var
msg: RawUTF8;
begin
fWebSockets := THttpClientWebSockets.Create;
fWebSockets.Open('echo.websocket.org', '80');
proto := TWebSocketProtocolChat.Create('echo', '', OnFrameReceived);
msg := fWebSockets.WebSocketsUpgrade('' {A}, '', True, false, proto);
if msg = '' then
Memo1.Lines.Add( 'ConnectToWebSockets: upgraded with protocol "EchoTest"')
else
Memo1.Lines.Add('Error: WebSocketsUpgrade: ' + msg);
end;
I keep on getting the result "Error: WebSocketsUpgrade: Invalid HTTP Upgrade Header".
I tried different things in {A}, e.g. echo.websocket.org, or wss://echo.websocket.org, I still get the same result.
Can anyone help me with this?
Thanks
Offline
Pages: 1