chrysn / aiocoap

The Python CoAP library
Other
267 stars 120 forks source link

Error in transferring data from libcoap server to aiocoap client #367

Open Koushik-ak47 opened 1 month ago

Koushik-ak47 commented 1 month ago

" Python version: 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)] aiocoap version: 0.4.11 Modules missing for subsystems: dtls: missing DTLSSocket oscore: everything there linkheader: everything there prettyprint: everything there ws: missing websockets Python platform: win32 Default server transports: oscore:tcpserver:tcpclient:tlsserver:tlsclient:simple6:simplesocketserver Selected server transports: oscore:tcpserver:tcpclient:tlsserver:tlsclient:simple6:simplesocketserver Default client transports: oscore:tcpclient:tlsclient:simple6 Selected client transports: oscore:tcpclient:tlsclient:simple6 SO_REUSEPORT available (default, selected): False, False "

I have tried sending large data using block mode transfer from libcoap server to aiocoap client. But the client is getting exit in between after 90 seconds of block transfer. The server code was tested with libcoap client code and it is working without any issue. Can you please solve the issue?

Hope you reply fast and solve this issue. I am attaching the client code here.

 import logging
import asyncio

from aiocoap import *
import aiocoap.numbers as numbers
logging.basicConfig(level=logging.INFO)
logging.getLogger("coap-client").setLevel(logging.DEBUG)

async def main():
    protocol = await Context.create_client_context()

    numbers.constants.TransportTuning.ACK_TIMEOUT = 20.0

    request = Message(code=GET, uri="coap://192.168.1.2:5683/get_service_log")

    try:
        response = await protocol.request(request).response
    except Exception as e:
        print("Failed to fetch resource:") 
        print(e)
    else:
        print("Result: %s\n%r" % (response.code, response.payload))

if __name__ == "__main__":
    asyncio.run(main())
Koushik-ak47 commented 1 month ago

I am getting an error if I execute the above script. I used the libcoap-user example as server code.

 ERROR:coap.blockwise-requester:Error assembling blockwise response, passing on error ResourceChanged()
 Failed to fetch resource:

On server side, I am receiving an error when I have enabled the debug logs in server code as well.

 DEBUG: COAP_EVENT_XMIT_BLOCK_FAIL

Please note this points as well. @chrysn can you help me out ?