It seems as though the boilerplate from the Typescript bot doesn’t connect to the runner. I’ve tried to dynamically generate the GUID but my suspicion is the UUID token isn’t getting passed correctly.
Just a heads up . Also any help in getting the bot working would be awesome!
Thanks!
** Here is the code I used to get it working, don’t ask me why, but it works ¯_(ツ)_/¯
import * as signalR from "@microsoft/signalr";
import process from "process";
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 ?? 'BotName';
const token = '762878c9-38e5-4963-9273-9d006ce2626c' ?? process.env.REGISTRATION_TOKEN;
const state = {
connected: false,
botId: "",
botState: null,
};
// Create a connection instance
const connection = new signalR.HubConnectionBuilder()
.withUrl(runnerURL) // Replace this with the URL of your SignalR hub
.configureLogging(signalR.LogLevel.Information) // Optional: Configure logging level
.build();
connection.on("Disconnect", (reason) => {
console.log("Disconnected with reason: ", reason);
});
connection.on("Registered", (botId) => {
console.log("Bot registered with ID: ", botId);
state.botId = botId;
});
connection.on("ReceiveBotState", (botState) => {
console.log("Received bot state: ", botState);
state.botState = botState;
});
connection.onclose((error) => {
console.log("Connection closed with error: ", error);
});
(async () => {
try {
// Start the connection
connection.start()
.then(() => {
console.log("Connection established successfully");
connection.invoke("Register", token, botNickname)
.catch((error: Error) => {
console.error("Error invoking Register:", error);
});
})
.catch((error: Error) => {
console.error("Error establishing connection:", error);
});
} catch (ex) {
console.error("Error connecting: ", ex);
}
})();