R
Railway12mo ago
Satan1c

503 with no reason

when I'm trying to make POST to my app endpoint, I'm getting 503 I put in body fields to update in DB, like id and amounts but when code comes to DB interactions, Railway send me 503 cuz Railway doesn't allow my app to log into console, I'm doing it in response body I've wraped all db calls with try-catch, but I doesn't get any response from them, but 503 from Railway
Solution:
it was just 0xC0000005
Jump to solution
22 Replies
Percy
Percy12mo ago
Project ID: f041c12e-a344-41f2-8269-546b53665885
Satan1c
Satan1cOP12mo ago
f041c12e-a344-41f2-8269-546b53665885
Satan1c
Satan1cOP12mo ago
no... application is responding but not in all cases
Brody
Brody12mo ago
ah, then make sure you are using https
Satan1c
Satan1cOP12mo ago
and I'm already using 0.0.0.0:PORT)
Brody
Brody12mo ago
i mean use https when making api calls
Satan1c
Satan1cOP12mo ago
oh, yep I do
Brody
Brody12mo ago
then your app is sending malformed responses back or you are sending malformed requests to railway
Satan1c
Satan1cOP12mo ago
hm... I'll add some data: 503(Railway response) body:
{
"label": "5",
"withdraw_amount": "1"
}
{
"label": "5",
"withdraw_amount": "1"
}
200(any my responses) bodies:
{
"label": "5",
"withdraw_amount": "0" // any less than 1
}

{
"label": "5",
}

{
"withdraw_amount": "5",
}

{ }

// or no body
{
"label": "5",
"withdraw_amount": "0" // any less than 1
}

{
"label": "5",
}

{
"withdraw_amount": "5",
}

{ }

// or no body
all invalid body variants are responds normally, cuz of my checks but if body is valid... it must find user in DB and create or update it's record but... for some reason when it comes to DB interactions, Railway sending me 503 first of all I was guessing that there throws some error on DB call but, after I've wrapped all DB calls in try-catch, I'm still getting 503 I can't tell is it again some trouble cuz of docker/linux but I can't do request on my app, if I'll run it locally in docker, without it all is great
cuz Railway doesn't allow my app to log into console
maybe if it was possible to do logs, it'll be much easier, but, I can't see any log on website
Brody
Brody12mo ago
why arent you using a proper database client to enter data into your database?
Satan1c
Satan1cOP12mo ago
that's for payment service webhook they send a big json, but atleast for now, I'm interested only in that two fields
Brody
Brody12mo ago
what do you see when you open your deploy logs?
Satan1c
Satan1cOP12mo ago
Nothing But when deploy removed, I see there all logs that my app was sending from very beginning
Brody
Brody12mo ago
are you using a dockerfile?
Satan1c
Satan1cOP12mo ago
As I remember from earlier trys, docker is the only option for C++, so yep, I use Dockerfile
Brody
Brody12mo ago
what logging library are you using?
Satan1c
Satan1cOP12mo ago
I use logs that included in drogon framework Bu I also tried cout and fpritf with stdout specification *drogon version from vcpkg
Brody
Brody12mo ago
please make sure you are not buffering your logs railway uses a line based scanner, so if you are buffering logs, the line scanner will not see any lines
Satan1c
Satan1cOP12mo ago
Hm... cout and other use streams for printing... So maybe that's the case, I'll look up for alternatives spdlog works just fine but... I'm still cant get any error logs
[02:59:54] info app init
[03:02:07] info before find
[03:02:07] info before casted
[03:02:07] info before filter
[03:02:07] info before doc
[02:59:54] info app init
[03:02:07] info before find
[03:02:07] info before casted
[03:02:07] info before filter
[03:02:07] info before doc
spdlog::get("console")->info("before casted");
auto casted = static_cast<int64_t>(id);

spdlog::get("console")->info("before filter");
auto filter = make_document(kvp("_id", casted));

spdlog::get("console")->info("before doc");
try {
const auto doc = m_collection.find_one(filter.view());
spdlog::get("console")->info("before return");
return doc.has_value();
} catch (const mongocxx::query_exception& err) {
spdlog::get("stderr")->error("mongocxx::query_exception");
spdlog::get("stderr")->error(err.what());
} catch (...) {
spdlog::get("stderr")->error("unknown error");
}

return false;
spdlog::get("console")->info("before casted");
auto casted = static_cast<int64_t>(id);

spdlog::get("console")->info("before filter");
auto filter = make_document(kvp("_id", casted));

spdlog::get("console")->info("before doc");
try {
const auto doc = m_collection.find_one(filter.view());
spdlog::get("console")->info("before return");
return doc.has_value();
} catch (const mongocxx::query_exception& err) {
spdlog::get("stderr")->error("mongocxx::query_exception");
spdlog::get("stderr")->error(err.what());
} catch (...) {
spdlog::get("stderr")->error("unknown error");
}

return false;
the worse that I can't trigger that on local to debug if there no errors... may be DB call doesn't sent... or maybe it self triggering Railway to do 503 response ?
Solution
Satan1c
Satan1c12mo ago
it was just 0xC0000005
Satan1c
Satan1cOP12mo ago
pepecringe
Want results from more Discord servers?
Add your server