Hello Guest

Client loose some packets...

  • 14 Replies
  • 18567 Views
*

Offline Yuri6037

  • ***
  • 104
  • Check out our website : http://www.sldt-team.net !
    • SLDT
Client loose some packets...
« on: November 20, 2013, 13:53:31 »
I have done a client - server game.
My client try to set up a connection to the distant server with the ip of the machine and the game port. That's work correctly the server recieve the ask and the server send the first packet (NetPacket1Init). The client answer correctly to the request.
But in-game, when the server send multiple packet at one time, the client handle correctly the first but others are completely lost... I don't understand why it does that.

In a better PC (Intel Xeon), the client handle all correctly.

I had found that this problem can be caused by too big packets.

If you wan't an architecture here is what I can give to you :

Client recieve integer by DataInputStream --> Client try to get the corresponding packet from the integer (Packet index) --> Client read the corresponding packet by call a function that take in parrameter the data input stream --> Packet do the nessessary by retrieving all values from DataInputStream --> Client handle now the packet by putting the content of the packet handling function in a runnable list --> BrickBroken main thread (or OpenGL context thread) will watch the runnable list and execute runnables in the OpenGL thread (nessessary because of change display things...)
All the client work is done in a single thread (Client network thread). All packet application code to the client is done in the OpenGL context thread : BrickBroken Main Thread !


Anyone has an idea about this problem ? Because it's very problematic to see a brick in-game that the server has destroyed but the client refuse to delete (packet never arrived to client).

Yuri6037

*

Offline Yuri6037

  • ***
  • 104
  • Check out our website : http://www.sldt-team.net !
    • SLDT
Re: Client loose some packets...
« Reply #1 on: November 20, 2013, 14:40:14 »
I have more :
It's not the client ! It's the server !

In effect the server is not writing correctly strings...
When you send 2 chat packets with same username but different message at the same time, the first is changing hiw values to the secound packet so the client recieve the two packets but the first has the second one data !

It only happened when using dataoutputstream.writeUTF(String s) ! Integers are functionnin perfectly only strings are changing values to secound packet ! So because all clients are identified by their player username, when the packets are writed, all is using writeUTF.
I would like to use integers to indentifiate players but it's impossible to generate randoms unique integers for all players ! I have searched for many times, but nothing can be integrated into BrickBroken server system...

If someone can find a function to correct the writeUTF problem, I will take...

Re: Client loose some packets...
« Reply #2 on: November 20, 2013, 15:52:27 »
Well code can always help. Its not so easy to understand what you mean. The second post really doesn't make much sense sorry.

Since there is not code i need to make assumptions. My first assumption is that you are using TCP and then streams on that. Can't see how else you use DataStreams otherwise. In that case the first thing i would check is, are you flushing streams? When you have finished sending some data/string or smallest unit you care about you should flush the stream.

Otherwise i can say with high confidence that packets are not getting lost. TCP will ack and resend anything that doesn't get through. If your streams don't throw some ioerror you should be fine and should assume the problem is on your side.
If you want a plot read a book and leave Hollywood out of it.

*

Offline Yuri6037

  • ***
  • 104
  • Check out our website : http://www.sldt-team.net !
    • SLDT
Re: Client loose some packets...
« Reply #3 on: November 20, 2013, 17:32:17 »
So thanks for your post and sorry, I'm french, I have some problems when I wan't to explain something !

For the code I can't give you the whole client (much more 1 millions lines of codes...), I can, on the other way, give you only the reading part of the client network thread (the OpenGL thread will not help you because it's rendering...).

Here is the code :
- Boolean disconnected is true when an error has been thrown and the network thread will be automaticaly killed by the OpenGL thread (the disconnected window do that killing work),
- packetManager refers to my NetClientPacket witch map all network packets,
- readFromNetwork : void witch retrieve all the packet content from DataInputStream,
- handle : void who contains commands destinated to OpenGL thread,
- theGame refers to the OpenGL thread,
- getNetPacketFromId : void that return the mapping packet (instance) from his index number,
- userInput refers to the DataInputStream of the current playing logged in user (each ClientNetwork instance has it's own DataInputStream and DataOutputStream).

Note that updateClient void is called when instantiate the network thread (only mounted if the connection to server has not failed).
Code: [Select]
--PRIVATE--


I hope you will be able to help now,
Yuri6037
« Last Edit: November 21, 2013, 14:29:34 by Yuri6037 »

Re: Client loose some packets...
« Reply #4 on: November 20, 2013, 21:31:41 »
Sorry that is not enough context. Are you using some network lib? You need to explain what your doing and what you expect, and even better get the smallest example that duplicates the bug. Also what i said before about flushing streams is something for the server as well.
If you want a plot read a book and leave Hollywood out of it.

*

Offline Yuri6037

  • ***
  • 104
  • Check out our website : http://www.sldt-team.net !
    • SLDT
Re: Client loose some packets...
« Reply #5 on: November 21, 2013, 08:54:00 »
Thanks for quick answer.

I'm using no librarys at whole client only luaJ and LWJGL nothing else ! Librarys do your work ! For me provide a good game is provide a game witch you do all your work... Don't let any library or other stuff touch your game. Otherwise you will get a f*cking game laggy (I was in this case with Slick2D) !

I need LuaJ only because I wan't to propose a addon system (like Minecraft Forge for Minecraft but in Lua).


So after to reproduce the bug, it's extremely hard ! You need my network system ! The problem is all my codes are protected, so I can not give you the whole networking system.

Only codes I can give is what you have on my precedent post.


I can, in another way tel you how this bug arrive.
There are several steps :
- Starting the server and the game,
- Connecting the game to the server,
- Try to chat something,
- The server read your chat without any problem,
- Server will now send your chat message with a debug info to all connected clients : First message to send is the chat message and the second is the debug information,
- When the game read all the two messages, it returns two chat message but the whole messages have taken the debug info. So you get two lines of chats : Debug info and debug info. You are not getting you chat message !

That's the bug.

I have told you that I'm French and I have learned Java without any help, well
I'm sorry but I don't know what do you mean by flushing the stream...
 

Can you help better ?
Yuri6037

Re: Client loose some packets...
« Reply #6 on: November 21, 2013, 09:18:07 »
you need to show the actual networking code. not just methods like  packet.handle(ClientNetwork.this); or packetManager.getNetPacketFromId(packetId); . Use pastebin.

If you don't understand what flushing a stream is, you have miss some very fundamental things with streams in general, not just with networking. I am sure there would be plenty of google results in french.
If you want a plot read a book and leave Hollywood out of it.

*

Offline Yuri6037

  • ***
  • 104
  • Check out our website : http://www.sldt-team.net !
    • SLDT
Re: Client loose some packets...
« Reply #7 on: November 21, 2013, 09:34:36 »
Do you mean washing the stream ? Because if is that, I think I have forgot that on the server side I will see if that's ok at server side.

Re: Client loose some packets...
« Reply #8 on: November 21, 2013, 09:40:05 »
The method is OutputStream.flush(); On any output stream, including DataOuputStream.

By the way. Washing is pretty funny :D
If you want a plot read a book and leave Hollywood out of it.

*

Offline Yuri6037

  • ***
  • 104
  • Check out our website : http://www.sldt-team.net !
    • SLDT
Re: Client loose some packets...
« Reply #9 on: November 21, 2013, 10:14:25 »
Now there is a big problem not linked to the add of flush !
The server is sending nothing ! I never seen this problem ! That's the first that happenned ! In plus when client connect now it connect not one time but 3 time now ! I don't understand !

I have modified nothing on the network system ! Don't understand !

In plus all multiplayer games such as Minecraft don't wan't to log to any server !
I get this message on Minecraft when try to login to any server : Failed to login : Bad login !

And I have bought this game !

I hope it's not my computer !

Can you help please ?
Yuri6037

Re: Client loose some packets...
« Reply #10 on: November 21, 2013, 10:20:06 »
You need to start at the beginning. Check your network. Then your code. Get the smallest example of a server/client that works... or doesn't work. Post that.

We won't fix minecraft however.
If you want a plot read a book and leave Hollywood out of it.

*

Offline Yuri6037

  • ***
  • 104
  • Check out our website : http://www.sldt-team.net !
    • SLDT
Re: Client loose some packets...
« Reply #11 on: November 21, 2013, 10:22:19 »
I have found the problem but I can't correct it !

It's IPV6 ! Windows says that I'm not connected to any network by my IPV6 only my IPV4 is connected to network !

So it's my computer !

Yuri6037

*

Offline Yuri6037

  • ***
  • 104
  • Check out our website : http://www.sldt-team.net !
    • SLDT
Re: Client loose some packets...
« Reply #12 on: November 21, 2013, 11:01:42 »
Network is back ! Minecraft is ok...

But my game is completely dead it recieve nothing !

So I will give you my whole client and server code !
Please not to bring my codes to your game... I don't wan't to get my game broken because of bad people who take other's codes...

ServerNetwork :
Code: [Select]
--PRIVATE--

ClientNetwork :
Code: [Select]
--PRIVATE--

--PRIVATE--

Yuri6037
« Last Edit: November 21, 2013, 13:38:49 by Yuri6037 »

*

Offline Yuri6037

  • ***
  • 104
  • Check out our website : http://www.sldt-team.net !
    • SLDT
Re: Client loose some packets...
« Reply #13 on: November 21, 2013, 13:44:01 »
First problem solved ! Someon on my team has modified the reading thread (change th packetId to 0 and not to readInt()) !

I will ban this f*cking guy from my team !


He has completely destroyed the client reading thread !

Ok one thin solved now the problem of multiple packets with same id witch not send correctly !



It rest the secound problem (or the first who I'm asking in the begening of this topic).
I will try to search by me for begin.

If I realy not see the problem I will contact you soon...

*

Offline Yuri6037

  • ***
  • 104
  • Check out our website : http://www.sldt-team.net !
    • SLDT
Re: Client loose some packets...
« Reply #14 on: November 21, 2013, 14:34:05 »
You know ; I'm stupid !

The problem was a mapping that was going out of the ass ! Thanks to me when I wan't to programm quickly without the head in place !

So problem solved !

In effect there was a stupid instance of NetClientPacket ! So when you chat 2 times the client is using the same instance of the packet mapped in my packetmanager ! So with a Class<? extends NetClientPacket>, it's better xD !


You can say that sometimes I'm very stupid !
You can say in plus : that was a NEWBIE programming error !