Client handle dropped messages.

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

truongps
Posts: 32
Joined: 27 Sep 2015, 17:06

Client handle dropped messages.

Postby truongps » 30 Sep 2016, 14:34

Hi,
- I'm trying SFS2X with my game. And now I'm testing it with slow network. I change network to bad with Network Link Conditioner.
Image

- And my game crash. It crashed because dropped messages.

Case 1: When I join room to play game, I don't receive SFSEvent.ROOM_JOIN, it is dropped. But I receive many in-game messages after. How can I fix this case? Can I request and get my current room on server, and update it to LastJoinedRoom in client?

Case 2: I don't receive SFSEvent.USER_EXIT_ROOM, SFSEvent.USER_ENTER_ROOM, they are dropped. And my game update UI base on UserList of LastJoinedRoom. So, I cannot find this user on client. And my game crash. So, how can I fix it? How can I update LastJoinedRoom on client?

Please give me a hand. Thank you!
Attachments
Screen Shot 2016-09-30 at 9.25.59 PM.png
(160.36 KiB) Not downloaded yet
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Client handle dropped messages.

Postby Lapo » 30 Sep 2016, 14:47

Hi,
I don't find it plausible that you don't receive the ROOM_JOIN event, unless the tool you're using is seriously messing up your network in which case I don't know how to help.

SmartFoxServer 2X drops messages only after having filled up a message queue that by default holds 120 messages. I find it implausible that the ROOM_JOIN gets dropped, unless you have fired another 120 requests prior to JoinRoomRequest at a very fast pace. Which is highly unlikely.

The same goes for the other two events, although at least those fall in the realm of plausibility if you're testing in a busy game Room with hundreds of messages being generated every few seconds and all clients are running on very limited bandwidth.

More details on dropped messages here:
http://docs2x.smartfoxserver.com/Gettin ... g#section4

hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
truongps
Posts: 32
Joined: 27 Sep 2015, 17:06

Re: Client handle dropped messages.

Postby truongps » 03 Oct 2016, 10:38

Hi,

I read an article on http://docs2x.smartfoxserver.com/ExamplesFlash/battlefarm. And I read "Handling slower connections" section. "In case the client can't keep up with the server message speed rate (e.g. after a network congestion) older messages are discarded to keep up with the latest game state". Does client skip some slow messages? If yes, please tell me how to keep all of them.

Thank you.
truongps
Posts: 32
Joined: 27 Sep 2015, 17:06

Re: Client handle dropped messages.

Postby truongps » 03 Oct 2016, 11:02

Hi Lapo,
I give you some log for detail.

Code: Select all

requestJoinJumpRoom
OnRoomJoin: 62235f12-52c7-40fe-a986-ed2e9f3501f1 with players: test67, test40, test6, test0, test70, test79, 0079e69c-3d17-4561-8b36-17081fa8a975, test59,
OnUserEnterRoom: [User: test8, Id: 8, isMe: False], players: test67, test40, test6, test0, test70, test79, 0079e69c-3d17-4561-8b36-17081fa8a975, test59, test8,
Uservars update for user test8 -> seat: [UVar: seat, type: INT, value: 8]
OnUserExitRoom [User: test67, Id: 67, isMe: False], players: test40, test6, test0, test70, test79, 0079e69c-3d17-4561-8b36-17081fa8a975, test59, test8,
OnUserEnterRoom: [User: test68, Id: 68, isMe: False], players: test68, test40, test6, test0, test70, test79, 0079e69c-3d17-4561-8b36-17081fa8a975, test59, test8,
Uservars update for user test68 -> seat: [UVar: seat, type: INT, value: 5]
Get user by username test59 return null. In room: [Room: 62235f12-52c7-40fe-a986-ed2e9f3501f1, Id: 6, GroupId: 2_2500] with remain players: test68, test70, 0079e69c-3d17-4561-8b36-17081fa8a975, test8,


First of all, I request and join a room. I received OnRoomJoin with 8 already players, include me and test59.
Second, I received many enter and exit room messages.
But, I don't received message test59 leave room. And I cannot find him when I get this user by Name like:

Code: Select all

public User findUser(string name) {
   for (int i = 0; i < this.sfs.LastJoinedRoom.PlayerList.Count; i++) {
      if (this.sfs.LastJoinedRoom.PlayerList [i].Name.Equals (name)) {
         return this.sfs.LastJoinedRoom.PlayerList [i];
      }
   }
   return null;
}


Why this.sfs.LastJoinedRoom.PlayerList don't have test59? Where is he?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Client handle dropped messages.

Postby Lapo » 03 Oct 2016, 15:19

No, the client does not drop messages. Only the server does according to what I said before and the link to the doc I provided.
According to your network limiter screenshot you have configured a "profile" that already drops 10% of the messages.

If you do that, it's pretty clear that messages will be lost. Simply don't :), as there is no remedy to that. If the network limiter trashes some packets client will of course misbehave.

cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
truongps
Posts: 32
Joined: 27 Sep 2015, 17:06

Re: Client handle dropped messages.

Postby truongps » 03 Oct 2016, 15:36

Hi Lapo,
I don't use this tool again. I run the game on ios device. It crashed and I check the log like above.

I think it because message order like the post http://www.smartfoxserver.com/forums/vi ... hp?t=18115
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Client handle dropped messages.

Postby Lapo » 03 Oct 2016, 17:22

I am not sure I follow you. We were talking about dropped messages, now it's message order?
They are two very different things.

I need more details to understand what you're trying to report. Give me a step by step description of what you're doing please.

thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
truongps
Posts: 32
Joined: 27 Sep 2015, 17:06

Re: Client handle dropped messages.

Postby truongps » 04 Oct 2016, 02:17

Hi Lapo,

I don't know what happen! I assume it could be one of such circumstances: dropped message or wrong message order or Smartfox client doesn't push some messages to my handler. Please, take a look in my log and explain this case to me.

Code: Select all

requestJoinJumpRoom
OnRoomJoin: 62235f12-52c7-40fe-a986-ed2e9f3501f1 with players: test67, test40, test6, test0, test70, test79, 0079e69c-3d17-4561-8b36-17081fa8a975, test59,
OnUserEnterRoom: [User: test8, Id: 8, isMe: False], players: test67, test40, test6, test0, test70, test79, 0079e69c-3d17-4561-8b36-17081fa8a975, test59, test8,
Uservars update for user test8 -> seat: [UVar: seat, type: INT, value: 8]
OnUserExitRoom [User: test67, Id: 67, isMe: False], players: test40, test6, test0, test70, test79, 0079e69c-3d17-4561-8b36-17081fa8a975, test59, test8,
OnUserEnterRoom: [User: test68, Id: 68, isMe: False], players: test68, test40, test6, test0, test70, test79, 0079e69c-3d17-4561-8b36-17081fa8a975, test59, test8,
Uservars update for user test68 -> seat: [UVar: seat, type: INT, value: 5]
Get user by username test59 return null. In room: [Room: 62235f12-52c7-40fe-a986-ed2e9f3501f1, Id: 6, GroupId: 2_2500] with remain players: test68, test70, 0079e69c-3d17-4561-8b36-17081fa8a975, test8,


Please focus on last log line.
Get user by username test59 return null. In room: [Room: 62235f12-52c7-40fe-a986-ed2e9f3501f1, Id: 6, GroupId: 2_2500] with remain players: test68, test70, 0079e69c-3d17-4561-8b36-17081fa8a975, test8,

First of all, I request and join a room and receive OnRoomJoin with 8 already players, including me and test59.
Second, I receive many enter and exit room messages.
But, I don't receive any message relating to test59 leaving room. But when I check this.sfs.LastJoinedRoom.PlayerList, the list doesn't contain the account 'test59', see the last log line, I get user test59 and cannot see him. Which message for updating LastJoinedRoom and PlayerList variables. They're owned by Smartfox client. What happen in Smartfox client?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Client handle dropped messages.

Postby Lapo » 04 Oct 2016, 09:07

Is this something you can replicate? If so I'd like to see the details.
Can you send us a proof of concept to reproduce it?
Lapo

--

gotoAndPlay()

...addicted to flash games
truongps
Posts: 32
Joined: 27 Sep 2015, 17:06

Re: Client handle dropped messages.

Postby truongps » 04 Oct 2016, 10:24

Hi Lapo, thank you very much for your collaboration.
This is a turn-based game (poker game) and it is always reproduced in the following steps:
Step 1: start 90 client instances (actually they are bots)
Step 2: 90 bots will connect to the smartfox server at the same time
Step 3: they join rooms which have only each 9 members per room (so, there are always 10 rooms with 9 bots each) and start the game
Step 4: every time the room finishes the last action (e.g, a member win the table), 9 members will automatically leave such room and will also automatically join another room. As you can see, 2 actions of the room feature such as leave and join, they are called in order. However, the interval is extremely short. The join room action of a specify client will be called right after the leave room action is responded from the server side.
Step 5: back and forth the steps (Step 3 - Step 4) until something wrong is happening!

Now, my truly question is:
- As you can see in the previous log, why doesn't the client side receive the "exit room" event while the "last joined room" user list is changed. In this case, the victim is "test59" and he is disappeared from the list.

Another question is, How does the Smartfox client handles data when I receive the log "[SFS2X INFO] Data Read: Size > 1024, dump omitted"

Your answer will be valuable to me. Really appreciate for your great support!
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Client handle dropped messages.

Postby Lapo » 04 Oct 2016, 10:47

A few comments:

Step 1: start 90 client instances (actually they are bots)
Step 2: 90 bots will connect to the smartfox server at the same time

Don't do this, it's unrealistic. If you start 90 clients in a for loop you will create a significant burst of traffic at one point in time causing an equivalent and larger burst back to the clients.

If you want to simulate a realistic situation introduce a little bit of delay between each connections, anything between 10-100ms for example.

Step 4: every time the room finishes the last action (e.g, a member win the table), 9 members will automatically leave such room and will also automatically join another room. As you can see, 2 actions of the room feature such as leave and join, they are called in order. However, the interval is extremely short. The join room action of a specify client will be called right after the leave room action is responded from the server side.

I am not sure why you need two requests here: leave and join.
In reality you just need to send a new JoinRoomRequest passing the new Room you want to join and the server will do both:
1- leave the current room
2- join the new one

This is perfectly synchronized and doesn't incur in the possible risk of going out-of-order that sending two requests has (which you can still avoid by waiting for the relative response before sending the next req)

- As you can see in the previous log, why doesn't the client side receive the "exit room" event while the "last joined room" user list is changed. In this case, the victim is "test59" and he is disappeared from the list.

Actually I don't see any timestamps in your logs so I am missing the times at which each event happens.
Aren't you using the standard logging?

I see that a few names have disappeared but it could be just a matter of timing. For example your logging happens in between the API removing the users that have left but before the relative event has been fired.

However I can't say because I don't know in which part of the code this output is generated.

Another question is, How does the Smartfox client handles data when I receive the log "[SFS2X INFO] Data Read: Size > 1024, dump omitted"

As already explained in another post, there's nothing different. Only the debug log will not show the full hexdump of the packet to avoid wasting resources in logging, which can be significant if the packet is big.

thanks
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Google [Bot] and 70 guests