Skip to content

Response timeout for block transfer #388

@dakhnod

Description

@dakhnod

Hey, thanks for your work!

I am running this code (taken from blockwise_put.js) to send a chunk of data:

const coap = require('../')

const bufferSize = 250000
const testBuffer = Buffer.alloc(bufferSize)
const containedData = 'This is a test buffer with a lot of nothing and a bit of something'
testBuffer.fill('X', 'utf-8')
testBuffer.write(containedData, 'utf-8')
testBuffer.write(containedData, testBuffer.length - containedData.length, containedData.length, 'utf-8')

const request = coap.request({
    hostname: 'fdd2:3ab9:44ef:78c5:3b48:3e87:df48:678e',
    port: 5683,
    pathname: '/test',
    method: 'PUT'
})
request.setOption('Block1', Buffer.from([6]))

request.on('response', (res) => {
    console.log('Client Received Response: ' + res.payload.toString('utf-8'))
    console.log('Client Received Response: ' + res.code)
    process.exit(0)
})
console.log('Sending large data from client...')
request.end(testBuffer)
console.log('Sent to server')

And this code (same source) to receive:

const coap = require('coap')

coap.createServer({ type: 'udp6' }, (req, res) => {
    setTimeout(() => {
        console.log('Server Received ' + req.payload.length + ' bytes')
        console.log('Sending back pleasantries')
        res.statusCode = '2.04'
        res.end('Congratulations!')
        console.log('Sent back')
    }, 500)
}).listen(() => {
    console.log('listening...')
})

Now, I am observing this behavior in wireshark:
image

And this error on the receiving side:

RetrySendError: No reply in 247 seconds.
at Timeout._onTimeout (/home/admin/coap/node_modules/coap/dist/lib/retry_send.js:56:25)
at listOnTimeout (node:internal/timers:581:17)
at process.processTimers (node:internal/timers:519:7)
Emitted 'error' event on OutMessage instance at:
RetrySend.emit (node:events:518:28)
at Timeout._onTimeout (/home/admin/coap/node_modules/coap/dist/lib/retry_send.js:58:22)
at listOnTimeout (node:internal/timers:581:17)
at process.processTimers (node:internal/timers:519:7) {
retransmitTimeout: 247
        inet6 fdd2:3ab9:44ef:78c5:0:ff:fe00:9c00  prefixlen 64  scopeid 0x0<global>                                                                                                       │}

While this is the stdout of the client:

Sending large data from client...
Sent to server
Client Received Response: Congratulations!
Client Received Response: 2.04

So, the reponse from the server seems to be parsed.

Do you have an idea why the packet is being retransmitted?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions