@@ -47,7 +47,7 @@ public function __construct(array $config)
4747 * @return mixed
4848 * @throws \Exception
4949 */
50- protected function runQuery ($ endpoint , mixed $ data , $ method = 'POST ' )
50+ protected function runQuery ($ endpoint , mixed $ data , $ method = 'POST ' , $ retry = 0 )
5151 {
5252 $ endpoint = trim ($ endpoint , '/ ' );
5353 $ url = $ this ->baseurl . '/ ' . $ endpoint . '?wait=true ' ;
@@ -62,6 +62,11 @@ protected function runQuery($endpoint, mixed $data, $method = 'POST')
6262 $ response = $ this ->http ->resp_body ;
6363
6464 if (!$ response ) {
65+ if ($ retry < 3 ) {
66+ sleep (1 + $ retry );
67+ return $ this ->runQuery ($ endpoint , $ data , $ method , $ retry + 1 );
68+ }
69+
6570 throw new \Exception (
6671 'Qdrant API returned no response. ' . $ this ->http ->error . ' Status: ' . $ this ->http ->status
6772 );
@@ -70,6 +75,11 @@ protected function runQuery($endpoint, mixed $data, $method = 'POST')
7075 try {
7176 $ result = json_decode ((string )$ response , true , 512 , JSON_THROW_ON_ERROR );
7277 } catch (\Exception $ e ) {
78+ if ($ retry < 3 ) {
79+ sleep (1 + $ retry );
80+ return $ this ->runQuery ($ endpoint , $ data , $ method , $ retry + 1 );
81+ }
82+
7383 throw new \Exception ('Qdrant API returned invalid JSON. ' . $ response , 0 , $ e );
7484 }
7585
0 commit comments