[micropython] Timeout socket doesn't work in LoRa

I’m noob with python and lora, I want to open a socket wait for a message, if there is no message then do something else, my code so far is:

from network import LoRa
import socket
import machine
import time
import binascii
import network

n = 0
try:
 the_sock = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
except:
   exit('Error creating socket.')
the_sock.settimeout(5)
while True:
    try:
        n+=1
        print("Hola"+str(n))
        time.sleep(1)
        the_sock.setblocking(True)
        ack = the_sock.recv(HEADER_SIZE)
    except socket.timeout, e:
        err = e.args[0]
        print(err)
        break`

The problem is that the timeout it’s not working, I’ve checked some answers but the code looks good to me, can you help me please?

Kind Regards

Is that with the LoPy? You could check out my example code that I’ve been using as an example for a workshop: https://github.com/brocaar/pycom-examples. This runs on the LoPy + PySense shield.

Yes it’s with the lopy, I’ve checked your code, but you don’t use the socket timeout, do you have one that uses it by any chance?

No sorry, I never tried. Note that you might want to re-post your question at https://forum.pycom.io :slight_smile: