TCP Communications on Browser

I am porting an Electron app for use in a static browser page (basically an html file and will be ran using the file:// protocol).

This Electron app is communicating with another app through TCP (127.0.0.1:port). For NodeJS, I am using the net module and it works perfectly fine.

But then, net module is not accessible in the browser and I can’t seem to find a module that supports TCP protocol on the browser (I’ve read that there is chrome tcp sockets, but it is already deprecated). Then there is also new technologies such as WebTransport but it feels like it is still in its very early stages and it seems to be using the http protocol somehow.

Instead, I tried using the native browser API for WebSockets (client-side). A pre-requisite for this is I need to run a server, so I used wc to create a server on the node side.

Now, my problem is, how can the external app (desktop app built using python) communicate with my server using TCP?

Another option I think I have is just create a local server using express and Axios and then still retain the TCP connectivity on the server side. I will use REST API to communicate between server-client.

But is there any other way to do this? Any other modules/technologies that allow using TCP on the browser?