• Post Reply Bookmark Topic Watch Topic
  • New Topic

socket problem

 
Doua Beri
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone. I have a small socket problem. I created a client / server app. everything is working fine. but if a client is connected to the server but not send or receive data for a certain period( around 10-15 minutes) the client will not communicate with the server. not sure why?
The server is running on centos

do I need to create a ping system. if yes how often should I ping the server.
Thanks in advance
 
Doua Beri
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it's an OS problem since the problem does not exists on windows. Only on linux systems. Anyone knows if there is something I should know about TCP sockets on linux?
I already used socket.setKeepAlive(true); but without any luck
 
Gert Jan Kruizinga
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like something has to time-out first before the connection setup can be completed and data-transfer can start. Do you connect through a DNS name (like host.company.com) our directly to an IP address?
 
Doua Beri
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gert Jan Kruizinga wrote:It looks like something has to time-out first before the connection setup can be completed and data-transfer can start. Do you connect through a DNS name (like host.company.com) our directly to an IP address?


I connect to an ip address. well after the connection is established everything is working ok. I I will not send any message for 10 -15 minutes it will stop sending messages for 15-20 seconds then it start sending them(so I have a 15-20 seconds lag) . after the lag period it starts sending messages normally and fast. I don't think it's a lag between client and server because I made a test with 100 clients sending a message every 5 seconds and it worked well without lag for 30-40 minutes.

This problem is only on linux. on windows everything is working ok.

I think linux puts the socket in standby until it is reused. do you know anything about this?
 
Gert Jan Kruizinga
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can check wath your socket is doing on the linux machine with the "netstat" tool. (replace the IP address with your own)

 
Doua Beri
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gert Jan Kruizinga wrote:You can check wath your socket is doing on the linux machine with the "netstat" tool. (replace the IP address with your own)



it shows me that the connection is established.
 
Prateek Parekh
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you add the IP address and hostname in /etc/hosts and try again?
 
Doua Beri
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prateek Parekh wrote:Could you add the IP address and hostname in /etc/hosts and try again?


I have checked the hosts file and I already have the ip there.
 
Doua Beri
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prateek Parekh wrote:Could you add the IP address and hostname in /etc/hosts and try again?


Also for new connections it does not appear. Only if I don't send or receive anything for a couple of minutes
 
ashu Suri
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you paste the code here.
 
Doua Beri
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ashu Suri wrote:Could you paste the code here.


I'm not sure it's the code, because this is working great on windows. works great on linux too , until you stop sending information through the socket. after that will have a 20 seconds lag. but all the messages are being sent.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!