luup.inet.wget question

I’m writing a plug-in to interface via IP to an emoncms temperature database running on a Raspberry Pi. Once per minute I do something like:

outgoingPDU = “http://192.168.0.59/emoncms/feed/list.json&userid=1
local status, result = luup.inet.wget(outgoingPDU,5)
if status == 0 then
points_data = json.decode(result)
– Do some processing
end

(The Pi sends back a json reply containing temperatures, battery info and so on.)

This works OK, but when I run it I get regular timeout errors on my security alarm comms (different plug-in) which uses luup.io.write and raw protocol, with Vera sending me incoming bytes. This works flawlessly, with no retries at all unless the emoncms comms are running. There’s nothing suspicious in the LuaUPnP log.

Am I missing something? If so, pointers appreciated!

Update: Problem occurs when both plug-ins send a message at the same time. Despite the fact that they are sending in different ways, to different URLs and using different ports, it seems that if messages are sent from the plug-ins at the same time Vera just stops responding to incoming data for periods between a few seconds and two minutes or so.

I am not surprised … LUA was not originally designed for multi-thread applications. Originally it was single thread with co-routines. There is likely some shared resource that is getting clobbered at the socket level that is causing the problem.

This will probably need a ticket raised to MCV to get resolved … I have not come across any of the details on the approach that MCV uses to host the LUA environment in a thread with it’s own LUA environment per device.

Thanks Richard - I’ll raise a ticket.

racarter, how do you respond to the luup.inet.wget on the Raspberry? I am trying to do something similar with an Arduino and know they are different, but it might give me a clue.

Thanks

Ned

I use:

local status, result = luup.inet.wget(outgoingURL,5)
if status == 0 then
points_data = json.decode(result)
end

Thanks racarter,

Actually, I was referring to how to get the raspberry to respond propperly to the wget. What do you do on the raspberry for formating. That sort of thing.

The Pi is running an emoncms data logger, logging temperatures into an SQL database and providing a web interface via an Apache server. My Vera plug-in asks the Pi for the data in .json format. I just installed the logger on the Pi - I didn’t write it.

Could you switch to using LuaSocket’s http.request instead of luup.inet.wget?

Hi,
I have similar setup. I am interested in emoncms plugin. I was wondering if I could build upon your work with the plugin.

Thanks

Abhinav Khandka

Abhinav

I’ve PMed you.

Sorry watou - I just noticed your suggestion. I tried both methods and got the same problem with each.

I agree with Richard that this deserves a trouble ticket to MCV, because socket I/O in one plugin ought to have no side effects on socket I/O in other plugins (assuming no plugin is “abusing” the APIs with excessive polling or resource consumption, which it doesn’t sound like you are doing).

watou

watou - The emoncms plug-in polls once per minute. The Texecom security alarm plug-in polls once every couple of seconds but works perfectly when the emoncms plug-in is not polling, so I don’t think I’m making unreasonable demands on the socket I/O.

I raised a ticket in March but have heard nothing since.

In the meantime I’ve got round the problem by modifying the Texecom plug-in to avoid polling for the first five seconds in each new minute, and arranging for the emoncms plug-in to poll only during that window.