Brewskey / spark-server

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
54 stars 27 forks source link

subscribe requests before claim #244

Closed durielz closed 7 years ago

durielz commented 7 years ago

Hi guys, after the claim process with softap the device is claimed successfully but for all the subscribe requests i get: device wasnt subscribed to event: the device is unclaimed It looks like the subscribe requests are processed before the claim...

jlkalberer commented 7 years ago

What softap are you using just so we have all the details?

durielz commented 7 years ago

https://github.com/spark/softap-setup-js but it's the same if you do it from the cli

jlkalberer commented 7 years ago

Ok, cool.

This should be a pretty easy fix then.

AntonPuko commented 7 years ago

@durielz Try new version, a device should reconnect after softap claiming now.

durielz commented 7 years ago

yes your solution work. I found another one without having to disconnect the device: in DeviceServer.js in function _onDeviceSubscribe if I move all code except await device.hasStatus(DEVICE_STATUS_MAP.READY); in the process.nextTick(()=> { it works as well but I don't know if it is the correct way...

jlkalberer commented 7 years ago

@antonpuko - check both and see which is cleaner

AntonPuko commented 7 years ago

@durielz ok, removing additional disconnect() is great, thanks.