Here we making 4 concurreny http requests to the endpoint with 2-seconds-delay before response, expecting them to run simultaneously.
And here is output:
As we can see, 2 later requests are waiting first 2 to complete, before executing. The same happends with telegram requests.
If request taking a long time (for example, sendVideo requests), others are waiting. And current default - 2 is very low.
Describe the bug Currently,
.setMaxConnTotal(100)
is used in https://github.com/rubenlagus/TelegramBots/blob/79ecff72243097f688ca42df6541869f02ce9db6/telegrambots/src/main/java/org/telegram/telegrambots/facilities/TelegramHttpClientBuilder.java#L30. This is a global connection count limit. There is second setting -setMaxConnPerRoute
: https://hc.apache.org/httpcomponents-client-4.5.x/current/httpclient/apidocs/org/apache/http/impl/client/HttpClientBuilder.html#setMaxConnPerRoute(int). As in case of telegram bot baseUrl is always the same, the second setting hits limit earlier than first one. As the default value is2
, this means, that only 2 requests could be performed simultaneously.To Reproduce Here is the quick test, to check, that this limit hits faster:
Here we making 4 concurreny http requests to the endpoint with 2-seconds-delay before response, expecting them to run simultaneously. And here is output:
As we can see, 2 later requests are waiting first 2 to complete, before executing. The same happends with telegram requests. If request taking a long time (for example,
sendVideo
requests), others are waiting. And current default -2
is very low.