Controlling Razberry from python with urllib2 much slower than through browser

Discussions about RaZberry - Z-Wave board for Raspberry computer
Post Reply
mjmare
Posts: 3
Joined: 18 Aug 2013 18:07

Controlling Razberry from python with urllib2 much slower than through browser

Post 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
User avatar
PoltoS
Posts: 7649
Joined: 26 Jan 2011 19:36

Try to sniff packet flow and

Post by PoltoS »

Try to sniff packet flow and see what happens.
mjmare
Posts: 3
Joined: 18 Aug 2013 18:07

I'm afraid that's beyond my

Post by mjmare »

I'm afraid that's beyond my expertise. Any pointers on how to proceed with that (on OSX)?
mjmare
Posts: 3
Joined: 18 Aug 2013 18:07

Found it!

Post 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?
Post Reply