[GH-ISSUE #148] cURL transport error: 35 OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to api.spotify.com:443 #93

Closed
opened 2026-02-27 19:26:00 +03:00 by kerem · 4 comments
Owner

Originally created by @alibaraneser on GitHub (Jan 31, 2019).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/148

Hey,

I'm using API in localhost, and I want to get tracks, but getting this error,

When it get 250 tracks and occur this error.

My Codes,

$getRandomSongsArray = array('%25b%25', 'c%25', '%25d%25', 'q%25', '%25i%25', 'i%25', '%25o%25', 'o%25');

        $count = 1;
        $total = array();
        $myfile = fopen(storage_path('app/public/data.txt'), "w") or die("Unable to open file!");

        do {
            $getRandomSongs = $getRandomSongsArray[array_rand($getRandomSongsArray)];
            $array = array('US','TR');
            $getRandomOffset = rand(1, 1000);
            $us_code = $array[array_rand($array)];
            $data =    $this->spotifyApi->search($getRandomSongs,['track'],[
                'market' => $us_code,
                'offset' => $getRandomOffset,
                'limit' => 50
            ]);
            // genre
            if($data->tracks->items) {
                foreach ($data->tracks->items as $item) {
                    $id = $item->artists[0]->id;
                    $genre = $this->spotifyApi->getArtist($id)->genres;
                    if ($genre) {
                        $genre = implode(",", $genre);

                    } else {
                        $genre = "";
                    }
                    $name = $item->artists[0]->name;
                    $spotify = $item->artists[0]->external_urls->spotify;
                    $txt = "$name \t $spotify \t $genre \n";
                    fwrite($myfile, $txt);
                }
                $total = array_merge($total,$data->tracks->items);
            }
            $count++;
            sleep(5);
        }while(count($total)<500);
        fclose($myfile);
Originally created by @alibaraneser on GitHub (Jan 31, 2019). Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/148 Hey, I'm using API in localhost, and I want to get tracks, but getting this error, When it get 250 tracks and occur this error. My Codes, ``` $getRandomSongsArray = array('%25b%25', 'c%25', '%25d%25', 'q%25', '%25i%25', 'i%25', '%25o%25', 'o%25'); $count = 1; $total = array(); $myfile = fopen(storage_path('app/public/data.txt'), "w") or die("Unable to open file!"); do { $getRandomSongs = $getRandomSongsArray[array_rand($getRandomSongsArray)]; $array = array('US','TR'); $getRandomOffset = rand(1, 1000); $us_code = $array[array_rand($array)]; $data = $this->spotifyApi->search($getRandomSongs,['track'],[ 'market' => $us_code, 'offset' => $getRandomOffset, 'limit' => 50 ]); // genre if($data->tracks->items) { foreach ($data->tracks->items as $item) { $id = $item->artists[0]->id; $genre = $this->spotifyApi->getArtist($id)->genres; if ($genre) { $genre = implode(",", $genre); } else { $genre = ""; } $name = $item->artists[0]->name; $spotify = $item->artists[0]->external_urls->spotify; $txt = "$name \t $spotify \t $genre \n"; fwrite($myfile, $txt); } $total = array_merge($total,$data->tracks->items); } $count++; sleep(5); }while(count($total)<500); fclose($myfile); ```
kerem closed this issue 2026-02-27 19:26:00 +03:00
Author
Owner

@jwilsson commented on GitHub (Jan 31, 2019):

Hello!
Could you try the steps here: https://github.com/jwilsson/spotify-web-api-php/issues/147#issuecomment-456694404 and let me know how that goes?

Could you also drop a phpinfo() somewhere and find the "SSL Version" value in the "curl" section?

Thanks!

<!-- gh-comment-id:459469834 --> @jwilsson commented on GitHub (Jan 31, 2019): Hello! Could you try the steps here: https://github.com/jwilsson/spotify-web-api-php/issues/147#issuecomment-456694404 and let me know how that goes? Could you also drop a `phpinfo()` somewhere and find the "SSL Version" value in the "curl" section? Thanks!
Author
Owner

@alibaraneser commented on GitHub (Jan 31, 2019):

I applied options code but there is still error.

phpinfo()

SSL Version OpenSSL/1.1.0g

define ('CURL_SSLVERSION_TLSv1_1',5);

$options = [
            CURLOPT_CAINFO => __DIR__ . '/cacert.pem',
            CURLOPT_ENCODING => '',
            CURLOPT_HEADER => true,
            CURLOPT_HTTPHEADER => $mergedHeaders,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
            CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1_1,
        ];
Additonaly, I tried CURL_SSLVERSION_TLSv1_2 but same result.
<!-- gh-comment-id:459533014 --> @alibaraneser commented on GitHub (Jan 31, 2019): I applied options code but there is still error. phpinfo() SSL Version | OpenSSL/1.1.0g -- | -- `define ('CURL_SSLVERSION_TLSv1_1',5); ` ``` $options = [ CURLOPT_CAINFO => __DIR__ . '/cacert.pem', CURLOPT_ENCODING => '', CURLOPT_HEADER => true, CURLOPT_HTTPHEADER => $mergedHeaders, CURLOPT_RETURNTRANSFER => true, CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4, CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1_1, ]; ``` Additonaly, I tried CURL_SSLVERSION_TLSv1_2 but same result. -- | --
Author
Owner

@jwilsson commented on GitHub (Feb 3, 2019):

@alibaraneser Hmm, are you running behind a proxy or something similar? Do you have another server to try it on?

<!-- gh-comment-id:460048339 --> @jwilsson commented on GitHub (Feb 3, 2019): @alibaraneser Hmm, are you running behind a proxy or something similar? Do you have another server to try it on?
Author
Owner

@jwilsson commented on GitHub (Mar 26, 2019):

Closing this due to a lack of activity.

<!-- gh-comment-id:476810322 --> @jwilsson commented on GitHub (Mar 26, 2019): Closing this due to a lack of activity.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-web-api-php#93
No description provided.