mainflux: Mainflux-mqtt exiting after sending an HTTP POST request.

When I tried this curl request as given in the tutorial, I got the output as follow:

Curl request:

curl -s -S -i -X POST -H "Accept: application/json" -H "Content-Type: application/json" http://localhost:7070/channels/fca48fe1-672a-424c-b219-a4fa6d62cc07/msg -d '[{"bn":"some-base-name:","bt":1.276020076001e+09, "bu":"A","bver":5, "n":"voltage","u":"V","v":120.1}, {"n":"current","t":-5,"v":1.2}, {"n":"current","t":-4,"v":1.3987}]'

Output:

mainflux-core    | [negroni] Started POST /channels/fca48fe1-672a-424c-b219-a4fa6d62cc07/msg
mainflux-core    | Msg written
mainflux-core    | [negroni] Completed 202 Accepted in 1.057578ms
mainflux-mqtt    | Received a message: {"topic":"mainflux/channels/fca48fe1-672a-424c-b219-a4fa6d62cc07","publisher":"","payload":"W3siYm4iOiJzb21lLWJhc2UtbmFtZToiLCJidCI6MS4yNzYwMjAwNzYwMDFlKzA5LCAiYnUiOiJBIiwiYnZlciI6NSwgIm4iOiJ2b2x0YWdlIiwidSI6IlYiLCJ2IjoxMjAuMX0sIHsibiI6ImN1cnJlbnQiLCJ0IjotNSwidiI6MS4yfSwgeyJuIjoiY3VycmVudCIsInQiOi00LCJ2IjoxLjN9XQ=="}
mainflux-mqtt    | /opt/mainflux-mqtt/mainflux-mqtt.js:86
mainflux-mqtt    | 		payload: Buffer.from(atob(m.payload)),
mainflux-mqtt    | 		                ^
mainflux-mqtt    | 
mainflux-mqtt    | TypeError: this is not a typed array.
mainflux-mqtt    |     at Function.from (native)
mainflux-mqtt    |     at Object.callback (/opt/mainflux-mqtt/mainflux-mqtt.js:86:19)
mainflux-mqtt    |     at Client.processMsg (/opt/mainflux-mqtt/node_modules/nats/lib/nats.js:892:11)
mainflux-mqtt    |     at Client.processInbound (/opt/mainflux-mqtt/node_modules/nats/lib/nats.js:824:14)
mainflux-mqtt    |     at Socket.<anonymous> (/opt/mainflux-mqtt/node_modules/nats/lib/nats.js:421:12)
mainflux-mqtt    |     at emitOne (events.js:77:13)
mainflux-mqtt    |     at Socket.emit (events.js:169:7)
mainflux-mqtt    |     at readableAddChunk (_stream_readable.js:146:16)
mainflux-mqtt    |     at Socket.Readable.push (_stream_readable.js:110:10)
mainflux-mqtt    |     at TCP.onread (net.js:523:20)
mainflux-mqtt    | 2017/01/16 10:59:18 Command exited with error: exit status 1
mainflux-mqtt exited with code 1

I tried the request with Postman (chrome extension) and got the same result. I have to restart the docker instance to get the mqtt up and running again. What might be the reason behind this? Thanks for all the help in advance.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (11 by maintainers)

Commits related to this issue

Most upvoted comments

@hashin commit https://github.com/mainflux/mainflux-mqtt/commit/070043878ec905095b34701ea1677c087711e45a should fix the issue. Problem was in the message encoding format in the payload byte array - Go JSON decoder encodes/decodes byte arrays in Base64 format (as you can see here: https://golang.org/src/encoding/json/encode.go), while Aedes uses UTF-8 buffers by default.