particle-iot / spark-server

UNMAINTAINED - An API compatible open source server for interacting with devices speaking the spark-protocol
https://www.particle.io/
GNU Affero General Public License v3.0
442 stars 136 forks source link

Error: Invalid CoAP version #69

Open robin13 opened 8 years ago

robin13 commented 8 years ago

I get errors like this:

Connection from: ::ffff:10.10.10.88, connId: 166
CryptoStream transform error TypeError: Cannot read property 'length' of null
CryptoStream transform error TypeError: Cannot read property 'length' of null
on ready { coreID: '3e0023000747343232363230',
  ip: '::ffff:10.10.10.88',
  product_id: 6,
  firmware_version: 65535,
  cache_key: '_165' }
Core online!
CryptoStream transform error TypeError: Cannot read property 'length' of null
Coap Error: Error: Invalid CoAP version. Expected 1, got: 0
routeMessage got a NULL coap message  { coreID: '3e0023000747343232363230' }
CryptoStream transform error TypeError: Cannot read property 'length' of null
CryptoStream transform error Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
Coap Error: Error: Unknown message code: 58
routeMessage got a NULL coap message  { coreID: '3e0023000747343232363230' }

I think this error CryptoStream transform error TypeError: Cannot read property 'length' of null is related to this PR but probably not merged yet.

I wonder about this one too though: Coap Error: Error: Invalid CoAP version. Expected 1, got: 0 - I see that a lot, and sometimes got: 2 or got: 3.

Any ideas?

dmiddlecamp commented 8 years ago

Hi @robin13 ,

Thanks for the ping! Yes I suspect they are related, it's a problem with the crypto library and newer versions of node. Sorry we haven't fixed this yet, everyone has been crazy busy, but changing node version or applying that patch to the local server should fix it.

Thanks, David

robin13 commented 8 years ago

Yes - applying the patch works.

There is still the odd output:

onSocketData called, but no data sent.
routeMessage got a NULL coap message  { coreID: '3e0023000747343232363230' }

But I am now getting publish events streaming. :)

chuank commented 8 years ago

@robin13, @dmiddlecamp,

Reporting similar issues with the NULL CoAP message on my local setup running Node 4.2.6 LTS, including the patch from spark/spark-protocol#14.

Also isolated this issue a bit further: this error shows up when a Photon is made to publish to the local cloud. Every time a publish is executed, the breathing cyan blinks and the server logs the 'NULL CoAP' error, before returning to breathing cyan right after. The publish event does make it through, but due to this error, there's a bit of a lag waiting for the Photon to recover the connection to the cloud. @robin do you notice your Photons blinking cyan when it publishes?

I tried using curl to manually publish the same event to the local cloud, and that works fine without error.

Screencap of my server log with a Photon repeatedly publishing and triggering the error on the server: image

Apologies for not being able to help beyond merely posting details of the errors; I just don't have the ability nor resources to dive into this. I'm just hoping that someone will be able to corroborate my findings and help to get to the bottom of this.

edit: similar, earlier discussion also referenced here #61 but I think this current issue is more specific to the NULL CoAP message.

chuank commented 8 years ago

@robin13 when your device(s) publish an event, do you notice it disconnecting briefly (blinking cyan) right after, before reconnecting?

Also, what version of node are you using?

chuank commented 8 years ago

Related fix can be found here: https://community.particle.io/t/error-when-publishing-on-local-server/19601