Client receive the second message before the 1st message

Sep 8, 2012 at 12:14 PM

Hi ,

In my app, some time server send two message to client ,

But the client receive the 2nd message and then receive 1st message,

How can I solve it,


Sep 8, 2012 at 12:15 PM

Which protocol are you using? Did you implement your protocol correctly?

Sep 8, 2012 at 12:35 PM

Hi kj , I'm use TCP

Sep 8, 2012 at 12:37 PM

What;s your application level protocol? You are sure to use TCP.


WebSocket or Command Line?

Sep 8, 2012 at 12:37 PM

I  mean the format of the data you send from server to client?

Sep 8, 2012 at 12:44 PM

Hi kj,

I use WebSocket ( HTML5 ) as my client side,

And the server host on IIS,

I use complete Supper web socket without any change,


Sep 8, 2012 at 12:46 PM

Your question should be asked on SuperWebSocket's website instead of SuperSocket.

Which version of SuperWebSocket are you using?

Sep 8, 2012 at 12:47 PM

How do you know the problem?

Sep 8, 2012 at 1:04 PM

On client side, when receive the message, I'm show it on screen and I see the problem,

On server side , I swap the code sending message to client and I the problem again, but change server side code just for detect problem because It will change the server logic,


Sep 8, 2012 at 1:06 PM

Which version of SuperWebSocket are you using?

And How do you send the message? Could show me the code?

Sep 8, 2012 at 1:07 PM

Now , I set break point for debug and wait about 2 minutes before send the 2nd message , client will receive correctly,

Sep 8, 2012 at 1:12 PM

I use SuperWebSocket 0.6  with SuperSocket 1.4 SP5

Sep 8, 2012 at 1:14 PM

Could you show me the sending code?

Sep 8, 2012 at 1:16 PM

The code :

            string JsonMessage_SlotInfo = "";

            CustomJObject.BuildJsonDataSucessWithRootKey(ref JsonMessage_SlotInfo, MessageDefine.RootKeyValue.ChangeSlotStatusResult);
            CustomJObject.FinalizeJsonData(ref JsonMessage_SlotInfo);




            string JsonMessageHostedMapInfo = "";
            Json_GetHostedMap_FullSuccessMessage(ref JsonMessageHostedMapInfo, ObjHostedMap.HostedUser.UserId);

            List<MapSlot> LstMapSlot = ObjHostedMap.GetListPlayerSlotHasPlayerJoinIn();

            for (int i = 0; i < LstMapSlot.Count; i++)
                if (LstMapSlot[i].UserId != ExcludeUserId)


And Send method is :

public void Send(string Message)
            this.WssInstance.SendResponseAsync(Message); // WssInstance is  WebSocketSession

Sep 8, 2012 at 1:21 PM

Your sending is async, so the order cannot be ensured.

Sep 8, 2012 at 1:28 PM

Thanks kj,  I'm change to SendResponse  and solve the problem,