Requests timeout

Posted on
Mon Nov 11, 2019 4:50 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Requests timeout

I'm getting nearer/further with the Tesla timeout.

Code: Select all
head = {'Authorisation': u'Bearer abcdefghihjklmnopqrstuvwyx'}
req = Request("https://owner-api.teslamotors.com/api/1/vehicles/123456789/data_request/vehicle_config", headers=head)
resp = urlopen(req)

Those three lines, with an appropriate auth code, should retrieve a JSON of vehicle data.

Instead they're instantly (<1 second) returning HTTPError 408: Request Timeout

I've added timeout=30 but it still fails in <1 second.
Code: Select all
head = {'Authorisation': u'Bearer abcdefghihjklmnopqrstuvwyx'}
req = Request("https://owner-api.teslamotors.com/api/1/vehicles/123456789/data_request/vehicle_config", headers=head)
resp = urlopen(req,timeout=30)

If I modify the auth to an invalid one, it returns 401 Unauthorised, so I know the auth is ok.

Any suggestions?

Peter

Posted on
Mon Nov 11, 2019 4:58 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Requests timeout

Ah, if i change it to http, not https, the timeout parameter starts to work - but it then errors with URLError not HTTPError.

Posted on
Mon Nov 11, 2019 5:29 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Requests timeout

The requests library (which is included with Indigo) may give you better information.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Nov 11, 2019 5:31 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Requests timeout

Ah, didn’t realise requests and Urllib2.Request were different.


Sent from my iPhone using Tapatalk Pro

Posted on
Mon Nov 11, 2019 5:36 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Requests timeout


Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Nov 11, 2019 5:55 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Requests timeout

:evil: :evil: :@~£&*/ :x *-+*/# :x #/,./! :oops: :oops: :oops:


Requests says "Vehicle not available"

So I POST the "wake_up" command.

Then suddenly Requests says "200 Ok"!

GRRR!

Posted on
Tue Nov 12, 2019 10:00 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Requests timeout

I read somewhere that there was at least consideration of making the requests module a standard part of Python. I wholeheartedly agree that it should happen. I think the rationale has been that keeping it out of the Python release cycle would allow for more frequent updates. But I think it's become fairly stable recently, and with the new commitment by the Python community to do yearly releases, that fear is significantly lessened.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Nov 12, 2019 10:41 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Requests timeout

If I was writing a plugin from scratch, I’d automatically go for requests because I’ve seen you and Joe comment on it so much.

Unfortunately Tesla was taken over from someone else, pre-written with urllib2.request, so I foolishly/blinkeredly thought it was the same thing.


Sent from my iPhone using Tapatalk Pro

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests

cron