Setting a Custom 404 Page
ffreality opened this issue · comments
Hi, I have some questions about LibHv after integrating it to Unreal Engine 5.
-
what is the difference between
server.start();
andserver.run();
-
If I use
auto Callback_Router_Handler = [this](const HttpRequestPtr& Request, const HttpResponseWriterPtr& Response) {};
as callback
- Should I use
hv::async::cleanup();
even if I useserver.stop()
?
Because project crashes with that callback if I also use thatasync::cleanup()
after restarting UE5 gameplay. - I can't use getter functions such as
Request->get()->GetParams();
after restarting Unreal Engine 5 gameplay.
It gives an error aboutfreeing memory
. So, I need to directly access variables like
const hv::QueryParams Querries = this->RequestPtr->get()->query_params;
- After setting a static web site with
router.Static("/", path_root),
How can I set a custom 404 page ?
1、HttpServer.run() will occupy current thread to run, but HttpServer.start() will create another thread to run.
2、Crash? Do you use /MD or /MT on windows? /MT may cause this case.
3、You can set HttpService::errorHandler to response a custom error page.
1、HttpServer.run() will occupy current thread to run, but HttpServer.start() will create another thread to run. 2、Crash? Do you use /MD or /MT on windows? /MT may cause this case. 3、You can set HttpService::errorHandler to response a custom error page.
I use /MD build on Windows. /MT build cause error with UE5.
You used server.setThreadNum(4);
with server.run();
If run occupy current thread, what is the goal of giving thread number ?
If you use server.setThreadNum(4); with server.run(); that will create 3 threads + current thread to run event loops,if server.start(), that will create 4 threads to run event loops, not occupy current thread.
-
I understand server.start() and .run() differences.
-
I solved error page workflow.
auto Callback_Router_Error = [this](const HttpContextPtr& Context)->int
{
return Context->sendFile(TCHAR_TO_UTF8(*this->Server_Path_404));
};
this->HTTP_LVH_Router.errorHandler = Callback_Router_Error;
gave expected correct result.
Only problems are
hv::async::cleanup();
gave crash after second start.- getter functions gave
FMEMORY_INLINE_FUNCTION_DECORATOR void FMemory::Free(void* Original)
crash.
I think they are about Unreal Engine 5. Some more exprienced developers said sometimes there could be clashes between third party libraries' memory system and Unreal's.
But I commented out hv::async::cleanup();
and it works normal. So, no need to keep open this issue.