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

client reset observe failed #154

Open
ghostyu opened this issue Oct 19, 2017 · 9 comments
Open

client reset observe failed #154

ghostyu opened this issue Oct 19, 2017 · 9 comments
Assignees
Labels
bug question RFC 7641 Issues related to RFC 7641 (Observe-Option)

Comments

@ghostyu
Copy link

ghostyu commented Oct 19, 2017

in client side, i want to send RST packet to server.

req.on('response', function(res) {
  console.log("---------------------response---------------------");
  console.log(res.headers);

  var rcvCount = 5;
  res.on('data', function(data) {
    console.log(data);
    rcvCount--
    if(rcvCount == 0){
      //it will throw new Error: Empty messages must be empty
      req.reset();
    }
  });
})
req.end()

when i call req.reset(), it will throw Empty messages must be empty error

@Pluuuto
Copy link

Pluuuto commented Nov 8, 2017

I have almost the same problem. When I am using "res.reset()" at server-end.

const coap = require('coap')

const server = coap.createServer()

server.on('request', (req, res) => {
  console.log(`Receive request: ${req.url}`)
  res.reset()
})

server.listen(5683, '127.0.0.1')

It will cause client-end throwing "Empty messages must be empty error". Using wireshark to capture and I find server-end sending NON msg with '5.00 Internal Server Error' and body 'Empty messages must be empty' after send RST msg.

image

NON msg has the same token with the NON request which client-end sent. I think this cause client-end throws error. I don't know why coap source code deal with reset on this way, maybe it's a bug? (reference to 'fastseries' lib)

@Pluuuto
Copy link

Pluuuto commented Nov 8, 2017

I found this is a bug because the RST msg has token. RFC7252-4.1 specific as follows:

image

The Error "Empty messages must be empty" is thrown by 'coap-packet' lib 'index.js':

image

And I check coap source code 'outgoing_message.js' and I find this:

image

packet.token is NOT set to null! I think this is the essential problem. After I add "packet.token = ''" at the following, the client-end doesn't thow the Error.

image

@GiedriusM
Copy link
Collaborator

@Pluuuto, I agree that this is a bug. Moreover, there seems to be more (un?)related problems that come out to the surface. There's also some difference depending if the client is on the same host as the server or not. Removing the token is a good first step, which fixes the stated problem, however as a side effect a program with a single coap request does not terminate (which may be another bug). If you want, you can submit a PR with the fix and tests that cover the scenario. If not I'll do it once I get to take a better look at all of the problems that this bug revealed.

@GiedriusM
Copy link
Collaborator

Please check if current master branch has this issue anymore.

@GiedriusM
Copy link
Collaborator

@ghostyu, @Pluuuto are we good to close this issue?

@robertbbb
Copy link

I seem to be having the same problem. Is there a branch where this bug was fixed?

@lucarv
Copy link

lucarv commented Jan 3, 2020

The issue exists in 0.23.1. I get the same error....
/app/node_modules/coap-packet/index.js:102
throw new Error('Empty messages must be empty')

@JKRhb
Copy link
Member

JKRhb commented Jun 16, 2021

@robertbbb @lucarv Could you give a bit more context under which conditions the error occured? (Sorry for the late follow-up question.)

@JKRhb JKRhb added the RFC 7641 Issues related to RFC 7641 (Observe-Option) label Oct 10, 2021
@cbiale
Copy link

cbiale commented Nov 15, 2023

This issue continue in the release 1.3.0. Any possibility of a solution or how to send an RST to the server in the case of observing. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug question RFC 7641 Issues related to RFC 7641 (Observe-Option)
Projects
None yet
Development

No branches or pull requests

8 participants