SSL Connection Problems

Hi, since switching to the new API i keep getting knocked off after about 30 seconds with:

The SSL connection could not be established

Using:

https://api.tfl.gov.uk/trackernet/PredictionSummary/{plus line code}/{plus app key etc}
and
https://api.tfl.gov.uk/trackernet/LineStatus/{plus app key etc}

I never ever got this with the old API

And i am not 100% but i think i kept getting this same error a lot last weekend as well.

thanks
Neil

Hi, I’m not sure if this is the problem or not, but may I suggest checking the request URL you’re using, and particularly how you’re sending the app_key?

The key should be sent either using an app_key HTTP request header or in the querystring. For example, either of the following curl commands should work (with your own key):

curl --header 'app_key: 0123456789abcdef0123456789abcdef' https://api.tfl.gov.uk/trackernet/PredictionSummary/J
curl https://api.tfl.gov.uk/trackernet/PredictionSummary/J?app_key=0123456789abcdef0123456789abcdef
1 Like

@LeonByford ok, thanks, i will have a look at how i am sending the HTTP request and see if it makes any difference

cheers
Neil

Hi @HighTrainsDrifter

I had the same issue. My solution involved upgrading php from 8.1 to 8.2 and adding the following to curl statement;

curl_setopt($ch, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NATIVE_CA);  

as in;

$url = "https://api.tfl.gov.uk/trackernet/PredictionDetailed/C/SFD?app_key=_appkey_";
..
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NATIVE_CA);  # (NOTE: added post php 8.2 upgrade and new tfl trackernet url )
$timeout = 3;
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$content = curl_exec($ch);

Mike

1 Like

@mikeflynn thanks for your reply but i am not using PHP i am calling the API directly from a windows app.

I actually found what the problem was (i think, because so far since the change i have not had an SSL problem)… i was using an extra character in my HTTP request that should not have been there… more than likely from using the same string as what i was using for the previous API.

Having the extra character allowed the first calls to go through and everything seemed fine but then it would crash with the SSL connection problem.

cheers
Neil

1 Like