amenzhinsky / iothub

Azure IoT Hub SDK for Golang
MIT License
51 stars 57 forks source link

Panic on received message #7

Closed brocaar closed 5 years ago

brocaar commented 5 years ago
panic: interface conversion: interface {} is nil, not string

goroutine 204 [running]:
github.com/amenzhinsky/iothub/common/commonamqp.FromAMQPMessage(0xc00040cbd0, 0x1)
        /tmp/iothub/common/commonamqp/message.go:51 +0xa68
github.com/amenzhinsky/iothub/iotservice.(*Client).SubscribeEvents.func1(0xc00040cbd0)
        /tmp/iothub/iotservice/client.go:208 +0x34
created by github.com/amenzhinsky/iothub/eventhub.SubscribePartitions
        /tmp/iothub/eventhub/client.go:132 +0x1e9

This is because the value is not a string:

https://github.com/amenzhinsky/iothub/blob/master/common/commonamqp/message.go#L46

fmt.Printf("%+v", msg.ApplicationProperties) returns:

map[stats:<nil>]

This happends when a device sends a message (using MQTT) to the following topic: devices/DEVICEID/messages/events/stats