Api_dash.js crashes on notification

I using MJS to send a notification from the device. I have used the example:

Dash.notify('Data', {temperature: 12.34});

But in the console I see
at api_dash.js: 18
at init.js: 176
MJS callback error: Use !==, not !=

Wierd thing is in my entire code there is nosuch !== or !=

The error is not in your code.
It is in api_dash.js

LE. Just created a PR to fix it.

1 Like

Has been fixed with this commit. Thank you @lsm for integrating it!
mos update latest to use it.

I updated to the latest but now the WSS has a 401. I have downloaded MOS.exe from the web link, and it runs well. So there must be something arround. Already try deleting the build directory if the case with no success

[Oct 24 19:56:30.853] dhcp client start…
[Oct 24 19:56:30.853] mgos_wifi.c:136 WiFi STA: Connected, BSSID 6c:3b:6b:fe:af:ab ch 1 RSSI -49
[Oct 24 19:56:30.853] mgos_net.c:90 WiFi STA: connected
[Oct 24 19:56:31.812] ip:172.16.1.214,mask:255.255.255.0,gw:172.16.1.1
[Oct 24 19:56:31.812] mgos_net.c:102 WiFi STA: ready, IP 172.16.1.214, GW 172.16.1.1, DNS 8.8.8.8
[Oct 24 19:56:31.812] mgos_provision_state:43 Current state: 1 -> 2
[Oct 24 19:56:31.812] mgos_rpc_channel_ws:261 0x3fff16bc Connecting to wss://mdash.net/api/v2/rpc, SSL? 1
[Oct 24 19:56:32.457] mg_ssl_if_mbedtls.c:35 0x3fff121c ciphersuite: TLS-RSA-WITH-AES-128-GCM-SHA256
[Oct 24 19:56:33.121] mgos_mongoose.c:66 New heap free LWM: 8576
[Oct 24 19:56:33.135] mgos_sntp.c:95 SNTP query to time.google.com
[Oct 24 19:56:33.293] mgos_sntp.c:59 SNTP reply from 216.239.35.8: time 1571957793.287088, local 27.612052, delta 1571957765.675036
[Oct 24 19:56:33.630] mgos_rpc_channel_ws.:52 0x3fff16bc WS handshake resp 401
[Oct 24 19:56:38.633] mgos_rpc_channel_ws:261 0x3fff16bc Connecting to wss://mdash.net/api/v2/rpc, SSL? 1
[Oct 24 19:56:39.290] mg_ssl_if_mbedtls.c:35 0x3fff3054 ciphersuite: TLS-RSA-WITH-AES-128-GCM-SHA256
[Oct 24 19:56:39.951] mgos_mongoose.c:66 New heap free LWM: 8280
[Oct 24 19:56:40.505] mgos_rpc_channel_ws.:52 0x3fff16bc WS handshake resp 401
[Oct 24 19:56:45.514] mgos_rpc_channel_ws:261 0x3fff16bc Connecting to wss://mdash.net/api/v2/rpc, SSL? 1
[Oct 24 19:56:46.025] mg_ssl_if_mbedtls.c:35 0x3fff2fac ciphersuite: TLS-RSA-WITH-AES-128-GCM-SHA256
[Oct 24 19:56:46.697] mgos_mongoose.c:66 New heap free LWM: 8160
[Oct 24 19:56:47.201] mgos_rpc_channel_ws.:52 0x3fff16bc WS handshake resp 401
[Oct 24 19:56:52.212] mgos_rpc_channel_ws:261 0x3fff16bc Connecting to wss://mdash.net/api/v2/rpc, SSL? 1
[Oct 24 19:56:52.726] mg_ssl_if_mbedtls.c:35 0x3fff7044 ciphersuite: TLS-RSA-WITH-AES-128-GCM-SHA256
[Oct 24 19:56:53.910]

If I return to the old mos.exe it connects OK to the WSS

[Oct 24 20:01:33.014] dhcp client start…
[Oct 24 20:01:33.014] mgos_wifi.c:136 WiFi STA: Connected, BSSID 6c:3b:6b:fe:af:ab ch 1 RSSI -50
[Oct 24 20:01:33.014] mgos_net.c:89 WiFi STA: connected
[Oct 24 20:01:33.577] ip:172.16.1.214,mask:255.255.255.0,gw:172.16.1.1
[Oct 24 20:01:33.577] mgos_wifi.c:144 WiFi STA: New current config: 1
[Oct 24 20:01:33.719] mgos_sys_config.c:174 Saved to conf9.json
[Oct 24 20:01:33.752] mgos_net.c:101 WiFi STA: ready, IP 172.16.1.214, GW 172.16.1.1, DNS 8.8.8.8
[Oct 24 20:01:33.752] mgos_provision_state:43 Current state: 1 -> 2
[Oct 24 20:01:33.752] mgos_provision_state:72 Setting provisioning timeout for 300 seconds
[Oct 24 20:01:33.752] mgos_mqtt.c:431 MQTT connecting to mdash.net:8883
[Oct 24 20:01:34.332] mg_ssl_if_mbedtls.c:35 0x3fff121c ciphersuite: TLS-RSA-WITH-AES-128-GCM-SHA256
[Oct 24 20:01:34.981] mgos_mongoose.c:66 New heap free LWM: 9400
[Oct 24 20:01:34.995] mgos_sntp.c:95 SNTP query to time.google.com
[Oct 24 20:01:35.159] mgos_sntp.c:59 SNTP reply from 216.239.35.8: time 1571958094.764766, local 9.219793, delta 1571958085.544973
[Oct 24 20:01:35.237] mgos_mqtt.c:141 MQTT TCP connect ok (0)
[Oct 24 20:01:35.483] mgos_mqtt.c:182 MQTT CONNACK 0
[Oct 24 20:01:35.525] mgos_provision_state:43 Current state: 2 -> 3
[Oct 24 20:01:35.525] mgos_provision_state:66 Reached stable state (3)
[Oct 24 20:01:35.665] mgos_sys_config.c:174 Saved to conf9.json
[Oct 24 20:01:35.684] mgos_mqtt.c:125 Subscribing to ‘device5/rpc/#’ (QoS 1)
[Oct 24 20:01:35.684] mgos_mqtt.c:125 Subscribing to ‘device5/rpc’ (QoS 1)
[Oct 24 20:01:37.310] requesting config by RPC…

401 means unauthorized.
Use mos config-set dash.enable=true dash.token=DEVICE_TOKEN to provision the device when using latest.

1 Like

Thanks!, now it works. Got confused about the mdash-setup config with this one. Does this following error has something to do with the size of the config?

--------------------------------------------------------------------------------
$ mos config-get device.id
E1025 09:07:44.930281    2892 stream.go:243] [streamConnectionCodec to COM8]: failed to parse     frame: "{\"id\":2017666984267,\"src\":\"esp8266_5E2CE6\",\"dst\":\"mos\",\"result\":}c4bb1c57" invalid character '}' looking for beginning of value
E1025 09:08:04.931301    2892 stream.go:243] [streamConnectionCodec to COM8]: failed to parse         frame: "{\"id\":1183149156042,\"src\":\"esp8266_5E2CE6\",\"dst\":\"mos\",\"result\":}a1a10a79" invalid character '}' looking for beginning of value
E1025 09:08:24.934632    2892 stream.go:243] [streamConnectionCodec to COM8]: failed to parse frame: "{\"id\":2081703089222,\"src\":\"esp8266_5E2CE6\",\"dst\":\"mos\",\"result\":}5e86299e" invalid character '}' looking for beginning of value
Error: context deadline exceeded
/go/src/github.com/mongoose-os/mos/common/mgrpc/mgrpc.go:460: 
/go/src/github.com/mongoose-os/mos/mos/dev/dev_conn_impl.go:167: 
/go/src/github.com/mongoose-os/mos/mos/dev/dev_conn_impl.go:190: 
/go/src/github.com/mongoose-os/mos/mos/dev/dev_conn.go:117: 
/go/src/github.com/mongoose-os/mos/mos/config/config.go:57: 
/go/src/github.com/mongoose-os/mos/mos/main.go:196: config-get failed
exit status 1

Command completed.

Also when I try to view the config file from the mDash web, the MQTT get disconnected and no config file is received:

[Oct 25 09:11:01.106] mg_rpc.c:293            Config.Get via WSS_out 148.251.54.236:443
[Oct 25 09:11:01.141] E:M 5751 (720 blocks)
[Oct 25 09:11:01.141] E:M 5623 (704 blocks)
[Oct 25 09:11:06.400] mgos_rpc_channel_ws:261 0x3fff17cc Connecting to wss://mdash.net/api/v2/rpc, SSL? 1
[Oct 25 09:11:07.042] mg_ssl_if_mbedtls.c:35  0x3fff13e4 ciphersuite: TLS-RSA-WITH-AES-128-GCM-SHA256
[Oct 25 09:11:07.709] mgos_mongoose.c:66      New heap free LWM: 7144
[Oct 25 09:11:08.225] mgos_rpc_channel_ws.:52 0x3fff17cc WS handshake resp 101
[Oct 25 09:11:08.345] mg_rpc.c:293            Sys.GetInfo via WSS_out 148.251.54.236:443

Looks like you are going low/out of memory:

[Oct 25 09:11:01.106] mg_rpc.c:293            Config.Get via WSS_out 148.251.54.236:443
[Oct 25 09:11:01.141] E:M 5751 (720 blocks)
[Oct 25 09:11:01.141] E:M 5623 (704 blocks)

I think is still broke @nliviun @lsm :

notify: function(name, data) {
if (typeof (data) !== ‘string’) data = JSON.stringify(data);
//let data = {cb: name, ud: data};
this._no(name, data);
},

_no: ffi(‘void mgos_dash_notify(char *, char *)’),

The step let data… get to an undefined cb (callback). Omitting this line work ok!

Created new PR.

Hi @nliviu. Do you know how long it takes for the PR to update?. Looking forward to deploy the first 5 devices to the client, but we need the Dash Notification.

Cheers
FBP

Instead of fixing the callback, the revert !== that was correct!. Now it has both errors:

Now it is:
if (typeof (data) != 'string') data = JSON.stringify(data);
let data = {cb: cb, ud: ud};

where it should be:

if (typeof (data) !== 'string') data = JSON.stringify(data);
//let data = {cb: cb, ud: ud};

Any news on this PR after 1 week?

Thanks
FBP