The current CoAP library can be used as a CoAP client for CON transaction. If the server isn't there, the transaction will timeout and the CoAP library raises the appropriate exception.
The problem is that it take a long time to time out (~140s). If the user mistyped the IPv6 address of the mote, he/she has to wait for that time.
What we need is a way of cancelling the transaction. The complicated part is that this requires the CoAP library to close its UDP binding. It's unclear at this point what the best way of doing that is in Python. Some options are:
delete the handler, maybe an exception is risen on the listening thread? (this is how pyserial works)
send a well-known string (e.g. "teardown") to the listening thread, which then returns. Of course, this allows for some nasty security attacks
1) use select for detecting when the socket_handler is closed (recvfrom does not unblock) 2) create a close() method in coapTrasmitter.py for aborting the state machine 3) keep a reference for the transmitter in coap.py for calling the close method
BUT, it was possible to remove the UDP injection. And I changed the storm app as well, now cancelling the last request gracefully.
Maybe you would like to take a look before any pull request.
Thomas Watteyne
July 13, 2014 at 6:31 AM
Fantastic, thanks for looking into this.
Marcelo Barros de Almeida
July 13, 2014 at 5:24 AM
I investigated all threads and references to the socket handler and I found a way to avoid this blocking. We needto make small changes in UDP real, transmitt and coap files for killing the socket, the reception thread and the coap state machine. I will test a little bit more tomorrow and describe the solution here.
The current CoAP library can be used as a CoAP client for
CON
transaction. If the server isn't there, the transaction will timeout and the CoAP library raises the appropriate exception.The problem is that it take a long time to time out (~140s). If the user mistyped the IPv6 address of the mote, he/she has to wait for that time.
What we need is a way of cancelling the transaction. The complicated part is that this requires the CoAP library to close its UDP binding. It's unclear at this point what the best way of doing that is in Python. Some options are:
delete the handler, maybe an exception is risen on the listening thread? (this is how
pyserial
works)send a well-known string (e.g. "teardown") to the listening thread, which then returns. Of course, this allows for some nasty security attacks