tcp_keepalive=yes has an effect on the underlying TCP connection. However, simply keeping the TCP connection alive will not stop the client or server WebSocket implementation explicitly closing the connection if no WebSocket frames are received.
If you are using WebSockets, and you are unsure as to the behaviour of the WebSocket client (some clients will send pings themselves and some won't - it's an implementation choice) the WebSocket server should send pings on idle connections that need to be kept open. If you want to make sure the underlying TCP connection doesn't go on you then you need to set the TCP connection parameters accordingly (the way I do it is to set the TCP connection timeout to a few seconds more than the WebSocket ping interval) - and do so for all LAN equipment in the path.
A good example is that if you are using Amazon Elastic Load-Balancer to distribute WebSocket connections, idle connections will be timed-out (by the Load-Balancer) after 60 seconds - so make sure the server sends WebSocket pings more frequently than that.
Regards,
Peter