Changed "Websocket Multiplayer Demo" to use wss, but getting "Connection closed", what am I doing wrong?

Godot Version



I have set up the Websocket Chat demo to use wss and the client be delivered by my webserver as HTML5. It works fine!

Now I want to do the same for the Websocket Multiplayer Demo, but the client won’t connect. I can’t work out what I’m doing wrong. Can anyone help please?

So far, in, I’ve added:

@export var tls_cert: X509Certificate
var tls_key: CryptoKey
var server_tls_options
var client_tls_options

func _onready():
    # tls_cert = set in Inspector and included in export
    tls_key = load("/home/tobyjones/Godot 4 Dev/certificates/privkey.key")  
    server_tls_options = TLSOptions.server(tls_key, tls_cert)
    client_tls_options = TLSOptions.client(tls_cert)

and changed:

func _on_Host_pressed():
    multiplayer.multiplayer_peer = null
    #OLD peer.create_server(DEF_PORT)
    multiplayer.multiplayer_peer = peer
    _game.add_player(1, _name_edit.text)
func _on_Connect_pressed():
    multiplayer.multiplayer_peer = null
    #OLD peer.create_client("ws://" + _host_edit.text + ":" + str(DEF_PORT))
    peer.create_client("wss://" + _host_edit.text + ":" + str(DEF_PORT), client_tls_options)
    multiplayer.multiplayer_peer = peer

and set the hostname to:

I’m exporting the app as HTML5 and serving via Apache, just as I did with the chat demo.

I’m probably missing something obvious - any help would be appreciated, thank you.