Controlling Razberry from python with urllib2 much slower than through browser
Posted: 18 Aug 2013 18:25
Hi all,
I have created a python web app to control my zwave devices through the Razberry. It works but I noticed that the calls to the REST API take much longer (4 to 5 seconds) than when entered directly into the browser (instant). Note that in both cases the identical command is issued.
I observe the same behavior for /ZWaveAPI/Run/ and /ZWaveAPI/Data commands.
I have also tried the Requests library but have the same problems.
My impression is that it is the connection that takes a long time to complete and not the actual reading of the data.
Example program:
import urllib2
urllib2.urlopen('http://picam02.local:8083/ZWaveAPI/Run/ ... 37].Set(0)')
Entering the same command in Safari yields instant response (the switch turns off).
Doing a read of an external site works flawlessly: urllib2.urlopen('http://www.apple.com').read() is very quick (and includes reading the data).
Any ideas anyone?
Marcel
I have created a python web app to control my zwave devices through the Razberry. It works but I noticed that the calls to the REST API take much longer (4 to 5 seconds) than when entered directly into the browser (instant). Note that in both cases the identical command is issued.
I observe the same behavior for /ZWaveAPI/Run/ and /ZWaveAPI/Data commands.
I have also tried the Requests library but have the same problems.
My impression is that it is the connection that takes a long time to complete and not the actual reading of the data.
Example program:
import urllib2
urllib2.urlopen('http://picam02.local:8083/ZWaveAPI/Run/ ... 37].Set(0)')
Entering the same command in Safari yields instant response (the switch turns off).
Doing a read of an external site works flawlessly: urllib2.urlopen('http://www.apple.com').read() is very quick (and includes reading the data).
Any ideas anyone?
Marcel