You are not logged in.
Pages: 1
Hi,
I have looked at this example of using a Websocket client: "WebSockets Client side" (https://synopse.info/forum/viewtopic.php?id=5291)
It shows using THttpClientWebSockets, and "upgrading" to use TWebSocketProtocolChat. Is this something that can only be used with a compatible mORMot Websockets server?
I am wanting to connect to an "aria2" websocket server. (It is an open source download manager. See https://aria2.github.io/manual/en/html/ … interface). Is this something I can do with mORMot websockets?
Thanks
Rael
Offline
Yes, with the THttpClientWebSockets, you can use any kind of WebSockets protocol.
Create your own protocol class, like TWebSocketProtocolChat, with the proper name.
Then assign the input/output frame events.
Online
I'm having trouble when calling fWebSockets.WebSocketsUpgrade
My code looks like this:
const
fServerURI = 'localhost';
var
fWebSocketsUri: RawUTF8;
msg: RawUTF8;
begin
fWebSockets := THttpClientWebSockets.Create;
fWebSockets.Open(fServerURI, '6800');
proto := TWebSocketProtocolChat.Create('aria2', '', OnFrameReceived);
fWebSocketsUri := StringToUTF8('ws://localhost:6800/jsonrpc');
msg := fWebSockets.WebSocketsUpgrade(fWebSocketsUri, '', True, false, proto);
if msg = '' then
Memo1.Lines.Add( 'ConnectToWebSockets: upgraded with protocol "aria2"')
else
Memo1.Lines.Add('Error: WebSocketsUpgrade: ' + msg);
end;
When fWebSockets.WebSocketsUpgrade is called I get an error:
"WebSocketsUpgrade: Invalid HTTP Upgrade Header"
Can you take a look, I prepared a demo project. To run the aria server just click on prompt.bat.
http://www.bauerapps.com/dev/AriaWebSocketsTest.zip
I will buy you a coffee...
Offline
Pages: 1