How to use urequests to post nonblocking data?

I’m using micropython library to post traffic on Xbee Cellular LTE Cat1 module. I find that is blocking, but would like to make it nonblocking. Digging into the library, I found that the socket can be made nonblocking by using the following command ‘s.setblocking(False)’. I then registered a polling object and then began polling the object using poll.poll(polling_ojbect). In, the very first socket command after creating the socket is ‘s.connect()’. I found that the response back from ‘s.connect()’ in nonblocking mode takes much longer than in blocking mode (~2 minutes vs ~2 seconds). This leads me to believe I’m doing something wrong. Is this the conventional method of nonblocking communication using micropython or is there a better way? Also, why the big difference in response times?

I don’t know if you are doing this or not but try putting the s.connect in a while loop.

Thanks mvut for your response. I did put it in a loop. I’m thinking that I will put put a timeout on the s.connect(), leave the socket open while I transmit, so that I don’t get hit by the connect time. Then enable the polling on just the response.