SOS - Im sinking... Need help with the Environmental Variables

Hi Everyone,

Having a very slow start this year. But have gotten to the point where its Entelect time for me.
I can already see my bot and its implementation.

But I have an issue.
I am unable to access the Engine Environmental Variables with the Javascript starter bot.

To Explain my setup:
I have the engine built, and when i run it it gives the following:
Determining projects to restore…
All projects are up-to-date for restore.
2023-07-19T17:11:31.2599399+02:00 Information - Starting System.Private.CoreLib
SignalR Confighttp://127.0.0.1:5000/runnerhub
COLLECTIBLE AMOUNT: 540
HAZARD AMOUNT: 134
Start position {X=23,Y=20}
COLLECTIBLE AMOUNT: 459
HAZARD AMOUNT: 219
Start position {X=29,Y=14}
COLLECTIBLE AMOUNT: 351
HAZARD AMOUNT: 314
Start position {X=464,Y=54}
COLLECTIBLE AMOUNT: 270
HAZARD AMOUNT: 155
Start position {X=245,Y=101}
2023-07-19T17:11:32.0852886+02:00 Information Runner.Services.CloudIntegrationService - Cloud Callback Initiated, Status: initializing, Callback player Count: 0
2023-07-19T17:11:32.1806268+02:00 Warning Runner.Services.CloudIntegrationService - Failed to make cloud callback with error: An invalid request URI was provided. Either the request URI must be an absolute URI or BaseAddress must be set.
2023-07-19T17:11:32.3209908+02:00 Information Microsoft.Hosting.Lifetime - Now listening on: “http://[::]:5000”
2023-07-19T17:11:32.3237590+02:00 Information Microsoft.Hosting.Lifetime - Application started. Press Ctrl+C to shut down.
2023-07-19T17:11:32.3240376+02:00 Information Microsoft.Hosting.Lifetime - Hosting environment: “Production”
2023-07-19T17:11:32.3240763+02:00 Information Microsoft.Hosting.Lifetime - Content root path: “D:\Entelect Challenge 2023\2023-Cy-Fi-2023.2.5\2023-Cy-Fi-2023.2.5\2023-CyFi\CyFi”
2023-07-19T17:11:32.4385686+02:00 Information Microsoft.AspNetCore.Hosting.Diagnostics - Request starting HTTP/1.1 POST http://127.0.0.1:5000/runnerhub/negotiate?negotiateVersion=1 - 0
2023-07-19T17:11:32.4496061+02:00 Information Microsoft.AspNetCore.Routing.EndpointMiddleware - Executing endpoint ‘“/runnerhub/negotiate”’
2023-07-19T17:11:32.4822819+02:00 Information Microsoft.AspNetCore.Routing.EndpointMiddleware - Executed endpoint ‘“/runnerhub/negotiate”’
2023-07-19T17:11:32.4830764+02:00 Information Microsoft.AspNetCore.Hosting.Diagnostics - Request finished HTTP/1.1 POST http://127.0.0.1:5000/runnerhub/negotiate?negotiateVersion=1 - 0 - 200 316 application/json 45.9932ms
2023-07-19T17:11:32.5047721+02:00 Information Microsoft.AspNetCore.Hosting.Diagnostics - Request starting HTTP/1.1 GET http://127.0.0.1:5000/runnerhub?id=CXw6UUyAV--Lq6B2VDOtnQ - -
2023-07-19T17:11:32.5049040+02:00 Information Microsoft.AspNetCore.Routing.EndpointMiddleware - Executing endpoint ‘“/runnerhub”’

I’m posting these in case my issue is with the runner itself, I did recompile a few times.

[2023-07-19T15:13:24.451Z] Debug: HubConnection connected successfully.
Error connecting: Error: Failed to invoke ‘Register’ due to an error on the server. InvalidDataException: Error binding arguments. Make sure that the types of the provided values match the types of the hub method being invoked.
at _callbacks. (D:\Entelect Challenge 2023\2023-Cy-Fi-2023.2.5\2023-Cy-Fi-2023.2.5\2023-CyFi\CyFi\Chaos2\node_modules@microsoft\signalr\dist\cjs\HubConnection.js:315:36)

So I have an issue with those variables passed.

I echod them out and it shows:
BotName: JSBOT
Token: Undefined.

I can access the Process.Env, those vars are just not in it (or anything similar).

I declared my register calls as:
import { HubConnectionBuilder, LogLevel } from “@microsoft/signalr”;

const runnerIP = process.env.RUNNER_IPV4 ?? “localhost”;
const runnerURL = runnerIP.startsWith(“http://”)
? ${runnerIP}:5000/runnerhub
: http://${runnerIP}:5000/runnerhub;

const botNickname = process.env.BOT_NICKNAME ?? “JSBot”;
const token = process.env.Token ?? process.env.REGISTRATION_TOKEN;

And then also:
(async () => {
try {
await connection.start();
await connection.invoke(“Register”, token, botNickname);
} catch (ex) {
console.error("Error connecting: ", ex);
}
})();

But seem to just not get there, I am running these with .sh files.

Do you have the Token or REGISTRATION_TOKEN environment variables set? I added a line afterwards that if both are null it just sets token to a random (valid) UUID, that seemed to work

I was looking at this solution and was afraid that it still causes issues.

I will take this approach for now so i can build.
Its very likely the server itself does not have the same problems / bugs as my development device.

Id normally tinker, but I want to do the actual AI.

So I will attempt this for certain…
Maybe someone else knows something.

Edit: The Manual UUID is working. I will revisit this a bit later. I thought they were generated by the runner.
Will run this manually for now, so i can at least build a bit.

I don’t know what your development setup looks like but I found that supplying the params as runtime parameters as oppsed to setting them on my machine’s environment produced better results.

I used this from last year’s bot in mine. Posted a pull request on gh as well.

const token = process.env[“REGISTRATION_TOKEN”] ?? createGuid();
function createGuid() {
return “xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx”.replace(/[xy]/g, function (c) {
var r = (Math.random() * 16) | 0,
v = c === “x” ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
}

Oh cool,

I used the crypto import method, But feel i will use this instead to not need that import…