Skip to content

CoAP Python client returns "No data received" exception #43

Description

@sumghai

I'm currently developing an application where one RPi 3 tells a second RPi 3 over a local wireless network to run selected macros (conditionCruise, conditionYellow and conditionRed):

from webiopi.clients import *
import webiopi
import time

# Connect to the RPi 3B+ running the Bridge Alert Light script
# Credentials are not needed, since both will be on a private network
client = PiHttpClient("192.168.1.101") 

# Setup function is automatically called at WebIOPi startup
def setup():	
	webiopi.sleep(1)

# Loop function is repeatedly called by WebIOPi 
def loop():
	value = Macro(client, "conditionCruise").call()
	time.sleep(6)
	value = Macro(client, "conditionYellow").call()
	time.sleep(6)
	value = Macro(client, "conditionRed").call()
	time.sleep(6)
	webiopi.sleep(0.05)
	
# Destroy function is called at WebIOPi shutdown
def destroy():
	webiopi.sleep(1)

The HTTP Python client works fine, but I'd like to switch to the CoAP Python client as a prelude to multicast communications to multiple remote RPis.

However, when I changed PiHttpClient to PiCoapClient, and enabled CoAP on my first Pi, the macros on the remote Pi aren't triggered, and the CoAP server hangs.

Running the WebIOPi service on the first Pi in debug mode reveals the following error message:

2016-12-25 12:02:53 - WebIOPi - INFO - Loading hsfm-entd-bridge-ctrlnode from /home/pi/hsfm-entd-bridge-ctrlnode/python/pi2pi_test.py
2016-12-25 12:02:54 - WebIOPi - INFO - Passwd file /etc/webiopi/passwd is empty
2016-12-25 12:02:54 - WebIOPi - WARNING - Access unprotected
2016-12-25 12:02:54 - WebIOPi - INFO - HTTP Server binded on http://192.168.1.100:8000/
2016-12-25 12:02:54 - WebIOPi - INFO - CoAP Server binded on coap://192.168.1.100:5683/
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.4/dist-packages/WebIOPi-0.7.1-py3.4-linux-armv7l.egg/webiopi/utils/thread.py", line 23, in run
    self.func()
  File "/home/pi/hsfm-entd-bridge-ctrlnode/python/pi2pi_test.py", line 19, in loop
    value = Macro(client, "conditionCruise").call()
  File "/usr/local/lib/python3.4/dist-packages/WebIOPi-0.7.1-py3.4-linux-armv7l.egg/webiopi/clients/__init__.py", line 107, in call
    return self.sendRequest("POST", values)
  File "/usr/local/lib/python3.4/dist-packages/WebIOPi-0.7.1-py3.4-linux-armv7l.egg/webiopi/clients/__init__.py", line 97, in sendRequest
    return self.client.sendRequest(method, self.path + path)
  File "/usr/local/lib/python3.4/dist-packages/WebIOPi-0.7.1-py3.4-linux-armv7l.egg/webiopi/clients/__init__.py", line 77, in sendRequest
    raise Exception("No data received")
Exception: No data received

It seems that Macro.call() expects a value to be returned from the remote Pi macros, so I added return 0 statements at the end of each macro on the remote Pi, but the error message persists.

Any ideas what I could try to fix this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions