heroiclabs / nakama-defold

Defold client for Nakama server.
https://heroiclabs.com
Apache License 2.0
74 stars 12 forks source link

"Received malformed payload" on match_data_send when upgrading to V3 #59

Open mlvhub opened 1 year ago

mlvhub commented 1 year ago

Hello, I followed the Defold+Nakama tutorial and created a similar game, then tried to upgrade the libraries to V3 and started getting errors on the server with "Received malformed payload".

I had some differences in code and setup so I continued my testing on the xoxo sample project branch and got the same results. Tried with multiple versions of the Nakama server and same thing.

Here's the decoded payload the server was complaining about:

{"match_data_send":{"op_code":1,"data":"{\"row\":1,\"col\":1}","match_id":"1325d106-4ea1-495f-be90-f0d33d73777c.nakama1"},"cid":"3"}

When going back to main and enabling debug level on the server but I could only find this message:

{"level":"debug","ts":"2022-10-26T19:35:35.207Z","caller":"server/pipeline.go:66","msg":"Received *rtapi.Envelope_MatchDataSend message","uid":"3a59222c-9749-4100-869f-0fe975a72be0","sid":"4cb4ce7b-5565-11ed-9018-7106fdcb5b46","cid":"3","message":{"MatchDataSend":{"match_id":"da0d6d5e-9665-4943-90af-785050561cdd.nakama1","op_code":1,"data":"eyJyb3ciOjEsImNvbCI6M30="}}}

There are some visible differences:

Not sure if they should match one to one though, could be a red herring.

britzl commented 1 year ago

Are you testing with the code on main or are you using the latest release?

The 3.0.3 version does not contain the fix for this issue

mlvhub commented 1 year ago

I'm testing the latest release, that explains it then, thanks.

britzl commented 1 year ago

I'm testing the latest release, that explains it then, thanks.

I've requested a new release which includes the fix.

https://github.com/heroiclabs/nakama-defold/pull/61

mlvhub commented 1 year ago

That's great, thank you! I can confirm both my project and the example project work by using the master branch.

ufgo commented 1 year ago

I also had such a problem on the release, now I have a message sent on the master, but it does not go further

function M.sendMessage()
    nakama.sync(function()
        local data = json.encode({
            row = 11,
            col = 22,
        })
        --data=base64.encode(data)
        local op_code = 1
        local result = nakama_socket.match_data_send(socket, matchID, op_code, data)
        print("sended")
        if result.error then
            print(result.error.message)
            pprint(result)
        else
            print("ok!!!")
        end
    end)
end

print("sended") - is not running

britzl commented 1 year ago

@ufgo which version of the Nakama client are you using? The fact that you don't see the print() indicates that something crashes in the coroutine, but for some reason the error is not shown (I'll look into this)-

britzl commented 1 year ago

but for some reason the error is not shown (I'll look into this)

Ah, logging is silent by default. Enable logging by doing this:

local log = require "nakama.util.log"
log.print()
ufgo commented 1 year ago

i use log. Nothing print about my problem only log in docker: nakama-nakama-1 | {"level":"debug","ts":"2022-10-30T08:44:37.293Z","caller":"server/pipeline.go:65","msg":"Received *rtapi.Envelope_MatchDataSend message","uid":"f590a664-17b8-436c-8b57-037106dd7f93","sid":"e65afced-582e-11ed-9223-7106fdcb5b46","cid":"3","message":{"MatchDataSend":{"match_id":"3cc2b731-0cc6-496d-b957-6468de15b112.","op_code":1,"data":"eyJjb2wiOjIyLCJyb3ciOjExfQ=="}}}

britzl commented 1 year ago

Can you share a minimal repro case so that I can take a look?

britzl commented 7 months ago

Closing due to inactivity. I was also not able to repro any problem myself.