Title: Error when two requests are too close in time · spotify-web-api-java/spotify-web-api-java · Discussion #367 · GitHub
Open Graph Title: Error when two requests are too close in time · spotify-web-api-java/spotify-web-api-java · Discussion #367
X Title: Error when two requests are too close in time · spotify-web-api-java/spotify-web-api-java · Discussion #367
Description: Error when two requests are too close in time
Open Graph Description: Hi, I'm getting this error when I make a request close after another (not always, it's a range, not inmediate and not long after it): java.lang.IllegalStateException: Connection 192.168.1.152:43204...
X Description: Hi, I'm getting this error when I make a request close after another (not always, it's a range, not inmediate and not long after it): java.lang.IllegalStateException: Connection 192.168.1.1...
Opengraph URL: https://github.com/spotify-web-api-java/spotify-web-api-java/discussions/367
X: @github
Domain: redirect.github.com
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"Error when two requests are too close in time","text":"\u003cp dir=\"auto\"\u003eHi, I'm getting this error when I make a request close after another (not always, it's a range, not inmediate and not long after it):\u003c/p\u003e\n\u003cdiv class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"java.lang.IllegalStateException: Connection 192.168.1.152:43204\u0026lt;-\u0026gt;35.186.224.25:443 is still allocated\n at org.apache.hc.core5.util.Asserts.check(Asserts.java:50) ~[httpcore5-5.2.2.jar:5.2.2]\n at org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager.getConnection(BasicHttpClientConnectionManager.java:306) ~[httpclient5-5.2.1.jar:5.2.1]\n...\"\u003e\u003cpre class=\"notranslate\"\u003e\u003ccode class=\"notranslate\"\u003ejava.lang.IllegalStateException: Connection 192.168.1.152:43204\u0026lt;-\u0026gt;35.186.224.25:443 is still allocated\n at org.apache.hc.core5.util.Asserts.check(Asserts.java:50) ~[httpcore5-5.2.2.jar:5.2.2]\n at org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager.getConnection(BasicHttpClientConnectionManager.java:306) ~[httpclient5-5.2.1.jar:5.2.1]\n...\n\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eFrom what I read this happens when using the BasicHttpClientConnectionManager and having more than one request open, depending on timing it will reuse the connection on create a new one.\u003cbr\u003e\nI'm making the calls using the synchronous execute, but using spring boot so executions are probably in different threads (I also tried with async calls and got the same issue).\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eIs there a way to avoid this (I may be using the API wrong)? Right now I have a wrokaround with a wrapper that catches the exception and retries, but asking in case there's a better way to handle this.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eThanks\u003c/p\u003e","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"\u003cp dir=\"auto\"\u003eYou're on the right track. You can try to \u003ca href=\"https://stackoverflow.com/a/14866394/4682621\" rel=\"nofollow\"\u003euse a pooling connection manager\u003c/a\u003e as \u003ccode class=\"notranslate\"\u003ehttpManager\u003c/code\u003e by \u003ca href=\"https://spotify-web-api-java.github.io/spotify-web-api-java/se/michaelthelin/spotify/SpotifyApi.Builder.html\" rel=\"nofollow\"\u003ebuilding a custom SpotifyApi instance\u003c/a\u003e.\u003c/p\u003e","upvoteCount":1,"url":"https://github.com/spotify-web-api-java/spotify-web-api-java/discussions/367#discussioncomment-7560730"}}}
| route-pattern | /_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format) |
| route-controller | voltron_discussions_fragments |
| route-action | discussion_layout |
| fetch-nonce | v2:a8e48309-02b2-a79f-b8c1-4a73e2491e09 |
| current-catalog-service-hash | 9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be |
| request-id | 8A8A:8C6A0:A79BD5:F0895C:6A6219DA |
| html-safe-nonce | 64126eabee15811212403fa6fbeec5b0fb8cceec4c26dcf1e89bffa9f3d07a9f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QThBOjhDNkEwOkE3OUJENTpGMDg5NUM6NkE2MjE5REEiLCJ2aXNpdG9yX2lkIjoiMzk1NTAzMjM1Mjk3NzE5NzUzMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e80ce4f7940e482a2c5abe4a557cc214ce810c065be1050a0ce35a4ccbead7fa |
| hovercard-subject-tag | discussion:5847938 |
| github-keyboard-shortcuts | repository,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/Voltron::DiscussionsFragmentsController/show/spotify-web-api-java/spotify-web-api-java/367/discussion_layout |
| twitter:image | https://opengraph.githubassets.com/9f3a0bbcc1ed594535982930842d602f10b53bceaff24a117d3d0d0c0fa84bf7/spotify-web-api-java/spotify-web-api-java/discussions/367 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9f3a0bbcc1ed594535982930842d602f10b53bceaff24a117d3d0d0c0fa84bf7/spotify-web-api-java/spotify-web-api-java/discussions/367 |
| og:image:alt | Hi, I'm getting this error when I make a request close after another (not always, it's a range, not inmediate and not long after it): java.lang.IllegalStateException: Connection 192.168.1.152:43204... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | ccf61cb7ab435725b916ed640f57c45b2c4721db9469bc32656080efc5214b3e |
| turbo-cache-control | no-preview |
| go-import | github.com/spotify-web-api-java/spotify-web-api-java git https://github.com/spotify-web-api-java/spotify-web-api-java.git |
| octolytics-dimension-user_id | 90800172 |
| octolytics-dimension-user_login | spotify-web-api-java |
| octolytics-dimension-repository_id | 18928344 |
| octolytics-dimension-repository_nwo | spotify-web-api-java/spotify-web-api-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 18928344 |
| octolytics-dimension-repository_network_root_nwo | spotify-web-api-java/spotify-web-api-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | a7585b3d2ee639495a70ce464d0a18bad88ea12c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width