Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paranthesis missing #16

Open
venkatajagannathtata opened this issue Nov 22, 2016 · 3 comments
Open

paranthesis missing #16

venkatajagannathtata opened this issue Nov 22, 2016 · 3 comments

Comments

@venkatajagannathtata
Copy link

Hi,

whenever I publish or subscribe we are missing "{" in the JSON. so finally it says invalid JSON payload to server. So app is unable to consume that JSON.

@venkatajagannathtata
Copy link
Author

venkatajagannathtata commented Nov 22, 2016

for a sample json like this { d = { text = "siva this is venkata" } }

after receiving in atleast once case its missing "{" and receiving like below.
I solved this as well. I am ready to share the changes . you are taking payload from 2nd character after dividing from header and payload combination.

d = { text = "siva this is venkata" } }

@bhargavg
Copy link
Collaborator

Sorry, but I didn't face this issue till now. It would be great if you could replicate this issue with a failing test case.

@venkatajagannathtata
Copy link
Author

venkatajagannathtata commented Nov 25, 2016

I have corrected in my code and the change is in MQTTPublishPacket.swift

`
if qos != .atLeastOnce {
messageID = 256 * UInt16(payload[0]) + UInt16(payload[1])
payload = payload.subdata(in: 0..<payload.endIndex)

        let datastring = NSString(data: payload, encoding: String.Encoding.utf8.rawValue)
        print(datastring)
        
    } else {
        messageID = 0
    }

`

Now if you notice your old code the payload.subdata line you are not starting from 0. You are starting from 2...which was the cause of that problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants