Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket client misses messages sent right after connection #389

Open
kittybwained opened this issue Jan 7, 2025 · 0 comments
Open

WebSocket client misses messages sent right after connection #389

kittybwained opened this issue Jan 7, 2025 · 0 comments

Comments

@kittybwained
Copy link

It seems that AWS's WebSocket client API misses messages that get sent immediately after connection roughly 8 out of 10 times.

I've tested this by opening a connection to wss://echo.websocket.org and waiting for a message, which sometimes comes and sometimes doesn't. Testing with an online WebSocket tester tool gets the message every time.

{661C5A4F-23B8-411E-B248-A822760CD556}

The code for the main program above is as follows:

with Ada.Text_IO; use Ada.Text_IO;
with AWS;
with AWS.Net.WebSocket;
with AWS.Net.SSL;
procedure Main is
	type MySocket is new AWS.Net.WebSocket.Object with null record;
	overriding procedure On_Message(Self : in out MySocket; Str : String) is
	begin
		Ada.Text_IO.Put_Line ("++ Got message '" & Str & "'");
	end On_Message;

	Socket : MySocket;
begin
	AWS.Net.SSL.Initialize_Default_Config(Security_Mode => AWS.Net.SSL.TLS_Client, Client_Certificate => "", Check_Certificate => True);
	AWS.Net.WebSocket.Connect(Socket,"wss://echo.websocket.org");
	while Socket.Poll(Timeout => 2.0) loop
		null;
	end loop;
	Socket.Close("");
end Main;

For reference, here's what an online WebSocket test tool shows after connecting and disconnecting a few times:
{3907D0FE-977C-49BF-BBE2-1992295B7A4D}

Unfortunately, some APIs (e.g. Discord's Gateway API) rely on the server sending a message immediately after connecting, preventing these APIs from being used with AWS.

Also, in case it matters, I tested this from a freshly-built AWS from the master branch with SOCKET=openssl, on Debian Testing running under WSL2 (so kernel 5.15.167.4-microsoft-standard-WSL2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant