Hello developers! My current issue is i have a discord bot thats on a hosting platform that works fine, and before i was hosting i was localhosting with a port and sending data between roblox and the bot.
now that i tried using the server IP along with the provided PORT on the server, it no longer works and i get a connect fail error when trying to send data the to JS file on the server.
i tried using IP 0.0.0.0:Port of my server here, but got the same issue, anyone know what i cna do?
below is the roblox code, data is for testing
local HttpService = game:GetService("HttpService")
local data = {
playerName = "yoda962",
level = 12,
rank = "Elite",
stats = {
kills = 45,
deaths = 7
}
}
local jsonData = HttpService:JSONEncode(data)
local success, response = pcall(function()
return HttpService:PostAsync("http://<ServerIP>:<Port>/roblox-data", jsonData, Enum.HttpContentType.ApplicationJson)
end)
if success then
print("Data sent successfully to the Express server.")
else
warn("Failed to send data: " .. response)
end
heres the node JS script, and of course for both my IP and port are hidden as it connects to my server
const express = require('express');
const app = express();
app.use(express.json());
let robloxData = {};
app.post('/roblox-data', (req, res) => {
robloxData = req.body;
console.log("Received data from Roblox:", robloxData);
res.sendStatus(200);
});
app.get('/roblox-data', (req, res) => {
res.json(robloxData);
});
app.listen(ServerIP, Port () => {
console.log(`Express server listening at http://<ServerIP><Port>:}`);
});