LuaSocket Help?
Posted: Tue Jan 29, 2019 2:18 am
Hello,
I am trying to network my game between client and server using Luasocket. However, I am having issues with getting consistent responses for fetching the world, especially when multiple clients are connected and disconnected. I wanted to ask if you could please review my code and let me know how I can improve it, so that I have consistent client connection/disconnections, and my server promptly responds to clients.
Here is the .LOVE files:
server: client: Here is also a Github repository (same code as above):
https://github.com/EliterScripts/tank-g ... aster/test
I ran this on Ubuntu Desktop (LTS 18.04) terminal. I found it easier to run the client by installing Luasocket via luarocks, and running "lua5.2 main.lua" directly from Lua 5.2. It helps a lot with simulating client abrupt termination by using ctrl+C in terminal. I'm not sure how to make the client abruptly disconnect using LOVE. However, I used LOVE2D to run the server.
To use Luasocket with Lua on Ubuntu/Debian Linux:
Install Luasocket via Luarocks:
Steps to Reproduce:
1. Rename "client.love" to "client.zip"
2. Unzip "client.zip"
3. Start server (in new terminal):
4. start first client (in new terminal):
5. start second client (in new terminal):
6. end second client (using ctrl+C)
7. start second client
8. You can close all the terminals and processes now.
To reproduce WITHOUT installing Luasocket via luarocks:
1. Start server (in new terminal):
2. start first client (in new terminal):
5. start second client (in new terminal):
6. end second client (using ctrl+Z)
7. start second client
8. You can close all the terminals and processes now.
Expected Results:
While the server and client(s) (is/are) on localhost, I expect the message from the client to the server to be accepted, processed, and responded to within less than 0.05 seconds, consistently, without the TCP connection dropping, regardless if or not if: it is the first time the client has been connected, disconnected, there are multiple clients connected to the server, or first time the server has connected to a client. I also expect that the server and client break/close the TCP connection if there has been no communication within 3 seconds, and the server delete any client objects when this happens.
Actual Results:
1. After step 1 ("Start server"):
The server starts, (output: https://paste.ubuntu.com/p/JBRsk8c6W5/), satisfactorily.
2. After step 2 ("start first client"):
The client connects, (output: https://paste.ubuntu.com/p/FfRvxpFSv3/), somewhat satisfactory. I don't like nor understand how/why it times out every other packet. However, the client is still receiving data.
The server accepts, (output: https://paste.ubuntu.com/p/SYdk6wvwPg/), somewhat satisfactory. I don't like nor understand how/why there is no consistency with the timing between the client sending data and console output.
3. After step 3 ("start second client"):
The second client connects, (output: https://paste.ubuntu.com/p/JjqJ6J9HNJ/), not satisfactory. I don't like nor understand how/why there is no consistency between timing out and received server message. It has a lot more packets that timed out than I want, every other 2-5 packets actually get received.
The first client (output: https://paste.ubuntu.com/p/QPgKGcSgrc/), not satisfactory. I don't like nor understand how/why packets start to time out more often when the first client connects.
4. After step 4 ("end second client"):
The second client disconnects (via ctrl+C).
The first client continues to drop more packets after the second client disconnects. (first client output: https://paste.ubuntu.com/p/TwPF2DySPK/).
The server disconnects with the client (output: https://paste.ubuntu.com/p/79rTqzx36H/) somewhat satisfactory. I think it keeps printing "clients: 2" far too long after the client has disconnected.
5. After step 5 ("start second client"):
The second client connects, but has %100 timeout packets (output: https://paste.ubuntu.com/p/HBnjdPZvbd/), absolutely unacceptable.
Server output: https://paste.ubuntu.com/p/RKBBWVqDsQ/
I really hope I was clear. I have tried this several times, and have failed. Please let me know if I need to provide any more details.
Thanks!
I apologize for duplicating threads, as I was not getting a response, and figured I would use a more appropriately named thread to ask for help.
I am trying to network my game between client and server using Luasocket. However, I am having issues with getting consistent responses for fetching the world, especially when multiple clients are connected and disconnected. I wanted to ask if you could please review my code and let me know how I can improve it, so that I have consistent client connection/disconnections, and my server promptly responds to clients.
Here is the .LOVE files:
server: client: Here is also a Github repository (same code as above):
https://github.com/EliterScripts/tank-g ... aster/test
I ran this on Ubuntu Desktop (LTS 18.04) terminal. I found it easier to run the client by installing Luasocket via luarocks, and running "lua5.2 main.lua" directly from Lua 5.2. It helps a lot with simulating client abrupt termination by using ctrl+C in terminal. I'm not sure how to make the client abruptly disconnect using LOVE. However, I used LOVE2D to run the server.
To use Luasocket with Lua on Ubuntu/Debian Linux:
Install Luasocket via Luarocks:
Code: Select all
$ sudo apt-get install lua lua5.2 luarocks
$ sudo luarocks install luasocket
Steps to Reproduce:
1. Rename "client.love" to "client.zip"
2. Unzip "client.zip"
3. Start server (in new terminal):
Code: Select all
$ love server.love
Code: Select all
$ lua5.2 main.lua
Code: Select all
$ lua5.2 main.lua
7. start second client
8. You can close all the terminals and processes now.
To reproduce WITHOUT installing Luasocket via luarocks:
1. Start server (in new terminal):
Code: Select all
$ love server.love
Code: Select all
$ love client.love
Code: Select all
$ love client.love
7. start second client
8. You can close all the terminals and processes now.
Expected Results:
While the server and client(s) (is/are) on localhost, I expect the message from the client to the server to be accepted, processed, and responded to within less than 0.05 seconds, consistently, without the TCP connection dropping, regardless if or not if: it is the first time the client has been connected, disconnected, there are multiple clients connected to the server, or first time the server has connected to a client. I also expect that the server and client break/close the TCP connection if there has been no communication within 3 seconds, and the server delete any client objects when this happens.
Actual Results:
1. After step 1 ("Start server"):
The server starts, (output: https://paste.ubuntu.com/p/JBRsk8c6W5/), satisfactorily.
2. After step 2 ("start first client"):
The client connects, (output: https://paste.ubuntu.com/p/FfRvxpFSv3/), somewhat satisfactory. I don't like nor understand how/why it times out every other packet. However, the client is still receiving data.
The server accepts, (output: https://paste.ubuntu.com/p/SYdk6wvwPg/), somewhat satisfactory. I don't like nor understand how/why there is no consistency with the timing between the client sending data and console output.
3. After step 3 ("start second client"):
The second client connects, (output: https://paste.ubuntu.com/p/JjqJ6J9HNJ/), not satisfactory. I don't like nor understand how/why there is no consistency between timing out and received server message. It has a lot more packets that timed out than I want, every other 2-5 packets actually get received.
The first client (output: https://paste.ubuntu.com/p/QPgKGcSgrc/), not satisfactory. I don't like nor understand how/why packets start to time out more often when the first client connects.
4. After step 4 ("end second client"):
The second client disconnects (via ctrl+C).
The first client continues to drop more packets after the second client disconnects. (first client output: https://paste.ubuntu.com/p/TwPF2DySPK/).
The server disconnects with the client (output: https://paste.ubuntu.com/p/79rTqzx36H/) somewhat satisfactory. I think it keeps printing "clients: 2" far too long after the client has disconnected.
5. After step 5 ("start second client"):
The second client connects, but has %100 timeout packets (output: https://paste.ubuntu.com/p/HBnjdPZvbd/), absolutely unacceptable.
Server output: https://paste.ubuntu.com/p/RKBBWVqDsQ/
I really hope I was clear. I have tried this several times, and have failed. Please let me know if I need to provide any more details.
Thanks!
I apologize for duplicating threads, as I was not getting a response, and figured I would use a more appropriately named thread to ask for help.