neffos icon indicating copy to clipboard operation
neffos copied to clipboard

[BUG] Message sent more than once

Open rwrz opened this issue 4 years ago • 2 comments

Describe the bug Sometimes the message sent arrives more than once on the server side. I can't reproduce the problem, it is happening with some of my clients, currently between an Android emulator and an Android device, on same network. Do I need to create some kind of MSG ID, and control messages that arrives more than once? And is that really possible? Currently, I'm using gobwas Dialers.

To Reproduce

  • Client send messages like this:
	// client sending message - ONCE
	c.Conn.Write(neffos.Message{
		Namespace: "default",
		Room:      "A_ROOM",
		Event:     "AN_EVENT",
		Body:      anyBytesArr,
		SetBinary: true,
	})
  • Server send messages like this:
	// server sending message - TWICE, since it arrives 2 times instead of one
	c.Conn.Server().Broadcast(c, neffos.Message{
		Namespace: "default",
		Room:      "A_ROOM",
		Event:     "AN_EVENT",
		Body:      anyBytesArr,
		SetBinary: true,
	})

Expected behavior Client send a message once, it arrives just once on server.

Logs Server logs: 2020/02/07 10:00:34 [e4e6f308-680d-4a36-ae06-e90d5c44c623][Room: A_ROOM][Event: AN_EVENT] 2020/02/07 10:00:34 [e4e6f308-680d-4a36-ae06-e90d5c44c623][Room: A_ROOM][Event: AN_EVENT]

Desktop (please complete the following information):

  • OS: [Linux, Android, GoMobile]
  • Version [Ubuntu 18.04.3 LTS, Android any, Go 1.13.4]

Additional context I'm using GoMobile to compile the client version and use it on an Android app (yay! works on iOS and Android!)

rwrz avatar Feb 07 '20 14:02 rwrz

Hello @rwrz,

Thanks for the report. I will find time to investigate it because currently I have no idea why it sends it twice. Could you please post the method you used to compile the client version on Android with GoMobile? (it could be added on wiki pages as well, you can fork).

Thanks, Gerasimos Maropoulos

kataras avatar Feb 07 '20 17:02 kataras

@kataras I'm just executing it, nothing different:

gomobile bind -target=android .

The "gomobile" trick is to create an interface with everything you want to expose to your app and this interface has a lot of limitations on its methods signatures. So, don't worry about how to compile it to "gomobile", it will work, just export a simple version of what you need.

About the twice problem, I tried to find something in the library code but seems ok to me. Maybe some "witchcraft" hidden somewhere!

Do you know if WebSockets, in general, is "at least once" kind of delivery? Maybe that's the problem.

rwrz avatar Feb 07 '20 19:02 rwrz