Client Websocket disconnect issue
Summary
When disconnecting a TCustomWebsocketClient with a OnDisconnected event assigned application crash because FConnection was FreeAndNil before.
System Information
- Operating system: Windows 11
- Processor architecture: x86-64
- Compiler version: 3.2.2 (With fcl-web and fcl-net from main branch)
- Device: Computer
Steps to reproduce
- Create a TWebsocketClient
- Assign a disconnection event
- Connect to a websocket server
- Invoke disconnect from client
Example Project
What is the current bug behavior?
Application crashes with access violation at fpwebsocketclient.pp:464
What is the expected (correct) behavior?
Disconnection of TWebsocketClient with OnDisconnect triggering
Relevant logs and/or screenshots
Example code:
FClient:=TWebsocketClient.Create(Self);
FClient.OnDisconnect:=@DoDisconnect;
[.. setting uri and connect...]
FClient.Disconnect(false);
Possible fixes
I've replace OnDisconnect(FConnection); with OnDisconnect(nil);
