xively / mosquitto

Ruby binding against libmosquitto (http://mosquitto.org/) - a high performance MQTT protocol (http://mqtt.org) client
Other
58 stars 15 forks source link

weird data decoding #10

Closed rolandjitsu closed 10 years ago

rolandjitsu commented 10 years ago

I'm using MQTTKit on a small iOS app to publish some data to the MQTT server and this library to subscribe in a small ruby program, but it seems like the data I receive looks very weird:

bplist00RST$topX$objectsX$versionY$archiver�Troot��
 !"#$%&'/;<=>JKLMU$null�

V$classZNS.objects����
                      ��

                        WNS.keys���   �
�
 �����UmajorUminor]proximityUUIDYtimestamp_$B9407F30-F5F8-466E-AFF9-25556B57FE6D_1400338443.678084�()*.X$classesZ$classname�+,-_NSMutableDictionary\NSDictionaryXNSObject_NSMutableDictionary�

���                           06�234��
   �����_$B9407F30-F5F8-466E-AFF9-25556B57FE6D_1400338443.678005�

                                                                 ?E�ABC�����
                                                                            �����_$B9407F30-F5F8-466E-AFF9-25556B57FE6D_1400338443.678049�()NQ�OP-\NSMutableSetUNSSet\NSMutableSet��_NSKeyedArchive(25:<TZ_fqswy{}��������������������
                                                                      $(>KTjqvxz|~����������������������*/3@FSXTj

I'm not sure if it is this lib or the other pod, but I have posted a comment here just to make sure that both parties are informed.

rolandjitsu commented 10 years ago

I have concluded that the issue was the way I was encoding the data, I was using a NSSet and converted it to NSData, but Ruby cannot read NSSet so I had to convert to JSON before to NSData.

I will close this issue as it has been resolved here.

methodmissing commented 10 years ago

We support UTF8 ( binary ) data for all messages - it may also have been that UTF8 was not your default encoding either. Messages in the MQTT spec are just binary blobs anyways ...

rolandjitsu commented 10 years ago

I think it was ASCII by default, but now that I'm encoding to JSON before sending the data it works perfectly.

Just have a short question @methodmissing, can the client be made as readonly (I think the C library has that options from what I've seen in the source code, but I might be mistaken or I misunderstood), just for subscribing and not being able to publish anything, since the publishing is done from the device?