Hi,

I am trying to test the websocket client in fcl-web by making a simple echo client. I have been unable to make it work using fpc trunk on linux64. I also crosscompiled to win64 and ran it on wine with identical results. The project is attached here if anyone can give some hints.

I am testing it with a server I found here https://github.com/vi/wsmirror (written in rust) but also I tried it with some public echo servers. There is a html/javascript websocket example also for testing it which is working.

I have no real guesses as to the problem. I modified the server that the client connects to enough to know when it receives messages and what kind. The server never identifies a proper message after the connection handshake is completed. It gets something but it doesn't identify it as a text message or ping or close etc. The server is dropping the connection after a few seconds with ss -t dport = 8080 giving this:

State             Recv-Q Send-Q                         Local Address:Port

CLOSE-WAIT            5 0                                127.0.0.1:47828

I believe those are several ping packets the server is sending that the client doesn't read.

One thing the websocket is doing is disabling MSG_SIGNAL so that when the pipe is broken it doesn't show an exception. However the component doesn't check for this and doesn't send the disconnect event.

I have made my own websocket component in the past which is working but I wanted to try the one included with fpc.

I'm really baffled, I spent a long time to try and find what is wrong, even putting debug code in the underlying socket components. And verifying that the websocket frames are correct.

An oddity I noted is that TInetSocket.CanRead seems to always return false if it's used as a client. I may not have understood that fully.

Regards,

Andrew Haines

<<attachment: websocket_echo_client.zip>>

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to