Hi folks!
I’m was busy (and a little bit lazy
), and because of this I was can’t tell you how did I fix my problem with the project.
In addition to the previous post
The WebSocketPeer in Godot Engine won't work
So, the first problem is that the project used connection through insecure protocols (http, ws), but must used only secure ones (https, wss), because browsers don’t accepts insecure connection, if your website itself use https. So, I must to fixed it.
First of all, and because I was be lazy, and didn’t want to get a bothering with TLS certs, I copied my Let’s Encrypt certs to the project. Only fullchain.pem to the client’s part, and fullchain.pem and privkey.pem to the server’s part, obviously. But I renamed fullchain.pem to fullchain.crt, and privkey.pem to privkey.key, so Godot Engine can recognize them.
But! Also the project use a small application. The server’s and client’s parts connects to that application and contacts with it. This application contacts to the database, and manages it. The server’s and client’s parts was written in Godot Engine, but the application for managing the database was written in Rust. All of this was written don’t by me for the first time, but when the Lead developer gone, because got done his job, I need to rewrite all of this
. But it doesn’t matter. So, the server’s and client’s parts now use the certs:
...
var http := HTTPClient.new()
var cert := X509Certificate.new()
cert.load(Constants.TLS_CERT_PATH)
assert(http.connect_to_host(_host_address, _host_port, TLSOptions.client(cert)) == OK)
...
But the problem left in the application’s part. The application use Actix-Web framework, and I must to add the certs to there. So, after I’ve add:
let mut builder = SslAcceptor::mozilla_intermediate(SslMethod::tls()).unwrap();
builder.set_private_key_file("certs/privkey.key", SslFiletype::PEM).unwrap();
builder.set_certificate_chain_file("certs/fullchain.crt").unwrap();
...
HttpServer::new( move || {
let cors = Cors::default()
.allow_any_origin()
.allow_any_method()
.allow_any_header()
.max_age(3600)
.send_wildcard();
App::new()
...
.app_data(Data::new(db_client.clone()))
.wrap(Logger::default())
.wrap(cors)
...
})
.bind_openssl((server_uri.get_host(), server_uri.get_port()), builder)
...
The project fully start works! ![]()
But with the one small detail: Exporting for the Web — Godot Engine (stable) documentation in English
I don’t know how much this necessary, but I’ve add a small delay between sending new packets. Just in case:
class_name Utils
static func create_delay(tree: SceneTree, frames: int) -> void:
for delay in range(frames):
await tree.process_frame
const AWAIT_FRAMES := 2
...
func _refresh() -> void:
await Utils.create_delay(_tree, AWAIT_FRAMES)
_active_abilities = await _db_client.get_all_active_abilities()
await Utils.create_delay(_tree, AWAIT_FRAMES)
_passive_abilities = await _db_client.get_all_passive_abilities()
await Utils.create_delay(_tree, AWAIT_FRAMES)
_cell_statuses = await _db_client.get_all_items()
await Utils.create_delay(_tree, AWAIT_FRAMES)
...
So now, everything works fine! ![]()
![]()