You can do just fine with websockets game, but the difficult part is deciding on a server to maintain game sessions and state. If someone drops off for 3 seconds, how is the game handled? Using a self-hosted (or on AWS, Vultr) server is one way: https://github.com/colyseus/colyseus
I think there are hosting game servers out there, Google Cloud seems to have one: https://cloud.google.com/game-servers
It would be possible to forego a server, but the two (or more) machines would have to know each other's IP addresses.