antoniodipinto / ikisocket

🧬 WebSocket wrapper with event management for Fiber https://github.com/gofiber/fiber. Based on Fiber WebSocket and inspired by Socket.io
MIT License
123 stars 21 forks source link

BUG : Inconsistent Message Sending #22

Closed talksik closed 2 years ago

talksik commented 2 years ago

Sometimes the client gets the full marshalled json, but sometimes, the client gets a JWT token starting with "ey..."

Any ides why? I know that for sure I am not sending a jwt token back. There seems to be some sort of race condition on the EmitTo.

when it does NOT work: "eyJldmVudCI6InN0YXJ0ZWQgc3BlYWtpbmciLCJkYXRhIjp7Im1vcmUgaW5mb3JtYXRpb24iOiIiLCJ0ZXN0IjoiIGFzZGZhZHNmIn0sImZyb21fdXNlcl9pZCI6ImFudGhvbnkifQ=="

when it does work, I get the full json as expected { "event": "someone_joined", "data": [ "arjun" ], "from_user_id": "arjun" }

antoniodipinto commented 2 years ago

Hi @talksik ,

It's a very strange behavior, especially because the string that you mentioned starting with "ey" it's a base64 string.

If I decode the string, I have this

{"event":"started speaking","data":{"more information":"","test":"asdfadsf"},"from_user_id":"anthony"}

I will check what's going on there

talksik commented 2 years ago

oooo thank you so much Antonio!!!

You actually helped me solve it! I was marshalling twice in some instances. Thank you for looking into this and figuring out that it's base64 👍🏾

Also, thank you so much for your work on this project! I can't thank you enough as I needed something simple and on top of fiber!