Open PremSahooESL opened 1 year ago
Something must be wrong with the connection url
Connection has been established. It also gets triggered upon events arrival. But with the below error
ERROR message parse error: invalid semicolon separator in query
Below is the sample connection URL I used:
HostName=xxxxxxx.azure-devices.net;SharedAccessKeyName=device;DeviceId=MY_GO_TEST;SharedAccessKey=xxxxxxxxx
Hi, @amenzhinsky is there any update?
@amenzhinsky Do you have any concerns on above connection string format? If so then how come the client could get authorized with above connection string format. But could not parse the data and throws parse error.
Is this SDK able to receive data in your case?
@PremSahooESL it seems parseCloudToDeviceTopic fails to parse the topic name of the incoming message, could you log it in your app to investigate what causes the problem?
Thanks for the response. Sure let me check..
Below is the Topic Name What I received from: This could not be parsed by parseQuery() function on url.go
$.to=/devices/PREM_GO_TEST/messages/deviceBound&$.ct=text/plain; charset=UTF-8&$.ce=
Is it something different or unexpected which comes from C2D by IotHub?
That's odd, there's a preparation of this type of queries for the following parsing.
https://github.com/amenzhinsky/iothub/blob/master/iotdevice/transport/mqtt/mqtt.go#L280
Could you make sure that parseCloudToDeviceTopic
throws the error?
Below code throws the error:
parseCloudToDeviceTopic() -> ParseQuery() -> parseQuery()
func parseCloudToDeviceTopic(s string) (map[string]string, error) {
s, err := url.QueryUnescape(s)
if err != nil {
return nil, err
}
// attributes prefixed with $.,
// e.g. `messageId` becomes `$.mid`, `to` becomes `$.to`, etc.
i := strings.Index(s, "$.")
if i == -1 {
return nil, errors.New("malformed cloud-to-device topic name")
}
q, err := url.ParseQuery(s[i:])
if err != nil {
return nil, err
}
p := make(map[string]string, len(q))
for k, v := range q {
if len(v) != 1 {
return nil, fmt.Errorf("unexpected number of property values: %d", len(q))
}
p[k] = v[0]
}
return p, nil
}
I could see below line is missing from above code:
https://github.com/amenzhinsky/iothub/blob/master/iotdevice/transport/mqtt/mqtt.go#L280
https://github.com/amenzhinsky/iothub/commit/7eb906f6251679227fb62b5f05c5c1e3b7316b4f
Could you update to the latest version?
it works now. Thanks.
I will keep posting here if I face other issues. Infact this is the only Github repo for Go Lang SDK for Azure IoT Hub. Hope it supports all basic C2D functions.
i am just trying to send a C-2-D message.
I am trying to use below imports statement. But my application could not start up. It keeps throwing beolow error.
"github.com/amenzhinsky/iothub/iotservice"
Looks.... latest Eventhub client.go in this repo is not using latest amqp 1.0.1 lib
Below is the send() of latest amqp 1.0.1 lib code....
Go Version: go 1.19
ERROR message parse error: invalid semicolon separator in query