Repository: godot
Issue: HTML5 in Godot 3.2.3 Can't start WebsocketServer
Labels: platform:web,topic:porting,documentation

### Godot version

3.2.3

### System information

Ubuntu 20, NVidia 1680, 32 GB RAM

### Issue description

When starting a project in Linux, there is NO issue, my websocket server launches inside Godot engine and my python websocket client works perfectly.

The issue comes when I launch the HTML5 version of the game. It launches perfectly except from the fact that the WebSocketServer inside Godot engine doesn't run.

It gives the following error in the Browser console:

`Unable to start server [tmp_js_export.js:8:41782](http://localhost:8060/tmp_js_export.js)`

![error](https://github.com/godotengine/godot/assets/4933774/af840732-1996-4413-8039-41443a006c20)

The websocket code in GDSCRIPT is this:

              extends Node
              
              onready var robot_mesh = $Robot_Mesh
              # The port we will listen to
              const PORT = 9080
              # Our WebSocketServer instance
              var _server = WebSocketServer.new()
              
              func _ready():
	              # Connect base signals to get notified of new client connections,
	              # disconnections, and disconnect requests.
	              _server.connect("client_connected", self, "_connected")
	              _server.connect("client_disconnected", self, "_disconnected")
	              _server.connect("client_close_request", self, "_close_request")
	              # This signal is emitted when not using the Multiplayer API every time a
	              # full packet is received.
	              # Alternatively, you could check get_peer(PEER_ID).get_available_packets()
	              # in a loop for each connected peer.
	              _server.connect("data_received", self, "_on_data")
	              # Start listening on the given port.
	              var err = _server.listen(PORT)
	              if err != OK:
		              print("Unable to start server")
		              set_process(false)
              
              func _connected(id, proto):
	              # This is called when a new peer connects, "id" will be the assigned peer id,
	              # "proto" will be the selected WebSocket sub-protocol (which is optional)
	              print("Client %d connected with protocol: %s" % [id, proto])
              
              func _close_request(id, code, reason):
	              # This is called when a client notifies that it wishes to close the connection,
	              # providing a reason string and close code.
	              print("Client %d disconnecting with code: %d, reason: %s" % [id, code, reason])
              
              func _disconnected(id, was_clean = false):
	              # This is called when a client disconnects, "id" will be the one of the
	              # disconnecting client, "was_clean" will tell you if the disconnection
	              # was correctly notified by the remote peer before closing the socket.
	              print("Client %d disconnected, clean: %s" % [id, str(was_clean)])
              
              func _on_data(id):
	              # Print the received packet, you MUST always use get_peer(id).get_packet to receive data,
	              # and not get_packet directly when not using the MultiplayerAPI.
	              var pkt = _server.get_peer(id).get_packet()
	              var cmd = pkt.get_string_from_utf8()
	              print("Got data from client %d: %s ... echoing" % [id, cmd])
	              robot_mesh.move_robot(cmd)
	              _server.get_peer(id).put_packet(pkt)
              
              func _process(delta):
	              # Call this in _process or _physics_process.
	              # Data transfer, and signals emission will only happen when calling this function.
	              _server.poll()



And the python script is:

                  
                  import websocket
                  import time
                  
                  
                  def send_command(cmd):
                      ws.send(cmd)
                      print("Sent=",cmd)
                      time.sleep(0.1)
                  
                  
                  ws = websocket.WebSocket()
                  connected = False
                  while not connected:
                      try:
                          ws.connect("ws://127.0.0.1:9080")
                          connected = True
                      except ConnectionRefusedError:
                          print("Error in connecting retrying...")
                          time.sleep(0.1)
                  
                  while True:
                      #command = input("Enter command (move_right/move_left): ")
                      send_command("strafe_right")



Any ideas? Becuase as far as I see there is nothing wrong, I followed the documentation. Is this a bug an dis solved in future versions? God9ot 4.1 maybe?

THanks in advance




### Steps to reproduce

Create a Godot project, copy paset the websocket server script described here, assign it to a Node, and inside that node place a Mesh Instance with the name "Robot_Mesh". Export in HTML5 format, an drun it in the IDE of Godot.

### Minimal reproduction project

[projectwebsockets.zip](https://github.com/godotengine/godot/files/12457644/projectwebsockets.zip)
Here you have the entire project, hope it helps