Page 1 of 1

Controlling Razberry from python with urllib2 much slower than through browser

Posted: 18 Aug 2013 18:25
by mjmare
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

Try to sniff packet flow and

Posted: 18 Aug 2013 18:25
by PoltoS
Try to sniff packet flow and see what happens.

I'm afraid that's beyond my

Posted: 18 Aug 2013 18:25
by mjmare
I'm afraid that's beyond my expertise. Any pointers on how to proceed with that (on OSX)?

Found it!

Posted: 18 Aug 2013 18:25
by mjmare
I was using Bonjour/Avahi naming like "picam02.local" instead of a fixed IP address for my raspberry pi. This works fine usually. But with access to the Razberry it made the requests take about 5 secs instead of about 0.2 secs!
I don't know why when accessing the razberry through Safari this is not an issue I don't understand. Maybe Safari caches the IP address?