Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset of observe request fails after write to response #175

Closed
Merisho opened this issue Mar 20, 2018 · 2 comments
Closed

Reset of observe request fails after write to response #175

Merisho opened this issue Mar 20, 2018 · 2 comments
Labels

Comments

@Merisho
Copy link
Contributor

Merisho commented Mar 20, 2018

Hello. I see following behavior on CoAP server: after any notification write to response stream on observe request Error: Empty messages must be empty exception appears.

const coap    = require('coap')
    , server  = coap.createServer()

server.on('request', function(req, res) {
  if (req.headers['Observe'] !== 0)
    return res.end(new Date().toISOString() + '\n')

  var interval = setInterval(function() {
    res.write(new Date().toISOString() + '\n')
    res.reset();      //  <-------------- here it fails
  }, 1000)

  res.on('finish', function(err) {
    clearInterval(interval)
  })
})

server.listen(function() {
  console.log('server started')
})

I follow up with stack trace and can say that this happens because of not empty res._packet.options after first res.write (so if I do reset before first write there is no error).

Related: #154

@mcollina @GiedriusM Could you please advice?

P.S. When I do res._packet.options = [] manually before reset it seems to be ok (no exception), but how can I track that connection has been dropped? No 'end' events on client side for ObserveReadStream instance is triggered.

@stale
Copy link

stale bot commented Jul 13, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days. Please check if the issue is still relevant in the most current version of the adapter and tell us. Also check that all relevant details, logs and reproduction steps are included and update them if needed. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 13, 2020
@stale
Copy link

stale bot commented Jul 21, 2020

This issue has been automatically closed because of inactivity. Please open a new issue if still relevant and make sure to include all relevant details, logs and reproduction steps. Thank you for your contributions.

@stale stale bot closed this as completed Jul 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant