drogonframework / drogonframework/drogon

FATAL It is forbidden to run loop on threads other than event-loop thread - EventLoop.cc:266

Open
#1,515 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
14.3k
Forks
1.4k
Avg merge
1d 13h
Merged PRs (30d)
14

Description

**Describe the bug**
at runtime:
FATAL It is forbidden to run loop on threads other than event-loop thread - EventLoop.cc:266

**To Reproduce**
Steps to reproduce the behavior:
1. Try some links
2. Get this at runtime
3. Try another link
4. Everything is fine
example code:
```
#include
#include

class DrogonWrapper {
public:
DrogonWrapper(trantor::EventLoopThread & loop_a): loop__(loop_a) {}
auto getBody(const std::string & origin, const std::string & path) {
auto client = drogon::HttpClient::newHttpClient(origin, loop__.getLoop());
auto request = drogon::HttpRequest::newHttpRequest();
request->setMethod(drogon::Get);
request->setPath(path);
request->setPathEncode(false);
return (client->sendRequest(request));
}
private:
trantor::EventLoopThread & loop__;
};

int main() {
std::string origin = "https://api3.binance.com";
std::string path = "/api/v3/exchangeInfo";
auto loop = trantor::EventLoopThread();
loop.run();
DrogonWrapper wrapper(loop);
auto pair_result = wrapper.getBody(origin,path);
int result;
if ("" == pair_result.second->getBody())
{
result = 1;
}
else {
result = 0;
}
return result;
}
```
if path is "/api/v3/time" or "/api/v3/ping" , this error appears. When site is "https://www.apple.com/airtag/" this error appears again.
This error does not appear for "/api/v3/exchangeInfo" .

**Expected behavior**
No error I guess.

**Desktop (please complete the following information):**
- OS: Manjaro KDE
- Kernel: Linux 5.15.94-1 and 6.1.12-1
- Drogon version: 1.8.2
- compiler: GCC 12.2.1 20230201 and Clang 15.0.7

**Additional info**
For documentation of binance api : https://binance-docs.github.io/apidocs/spot/en/#market-data-endpoints

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.