coapjs / coapjs/node-coap

Response timeout for block transfer

Open
#388 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
552
Forks
154
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the client and server examples based on blockwise_put.js and compare the packet exchange with the retry reported at retry_send.js:56. Trace why the server response is parsed by the client while a retransmission remains pending. Done means the retransmission cause is explained and the block-transfer exchange no longer produces the reported timeout.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.