libwebsockets slow response on iOS device with network disconnect UE4.27

I am using libwesockets and establish a session with a server. When network is interrupted (eg. wifi goes off) the client receives a response LWS_CALLBACK_CLIENT_CLOSED. On Android, this is received instantly. On iOS it consistently takes about 1 minute to receive the callback. I can resolve this by using ping-pong with server, however the behaviour on iOS and Android will still be different for users.

Has anyone else encountered this problem and how have they resolved it?

I think that the latest version (4+) of libwesockets will provide a way to resolve this. How can I use the latest version of libwebsockets with UE4.27 as it currently includes version 3.0.0?

Similar issue with response from third party libwebsockets support:

The thirdparty libwebsockets currently in provided by Unreal: