Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (798)
Games in Android Showcase (234)
games submitted by our members
Games in WIP (865)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  java.net.SocketTimeoutException: connect timed out  (Read 38282 times)
0 Members and 1 Guest are viewing this topic.
Offline princec

« JGO Spiffy Duke »


Medals: 1107
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Posted 2014-11-11 09:45:03 »

So, Battledroid continues crawling along. I've come across a bit of an issue which doesn't bode well and will I suspect cause grave problems after any attempt at scaling.

I get a lot of seemingly random "java.net.SocketTimeoutException: connect timed out" when I try and connect to the Battledroid server. It's a TCP/IP connection on puppygames.net:25000.

95% of the time, the connection succeeds just fine, and the request is processed in a total of 450ms or so in its entirety. I'm polling the server once per second with this simple, tiny request (I think the payload is less than 100 bytes but that's neither here nor there). But every so often it'll just timeout attempting to connect. Changing the socket timeout to larger values (up to 20 seconds!) doesn't seem to fix it... it's like the initial connection is simply lost in space.

Probing the firewall logs I'm not seeing any evidence of rate limiting or blocking from the firewall (indeed, coming from my home machine, there are no firewall rules in the way to my Linux server).

This is perplexing. A ping never fails. A browse to www.puppygames.net never fails. Only my TCP/IP connections in-game (made by Java) are failing.

Has anybody any good ideas of how to proceed with diagnosing it?

<edit>

A little further information:
tcpview shows that we get as far as SYN_SENT status on the client. So presumably the preamble genuinely isn't reaching the server but is vanishing somewhere en route.

Cas Smiley

Offline ddyer
« Reply #1 - Posted 2014-11-11 18:52:44 »

It sounds like the actual problem is that the process providing the data is blocked.
A common error is assuming that sending a small amount of data will always
succeed quickly, when in fact it can block. 

Outside of the actual data transfer, other kinds of synchronization issues
among threads can stop progress; "socket timed out" is only a symptom.
Offline princec

« JGO Spiffy Duke »


Medals: 1107
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #2 - Posted 2014-11-11 19:08:10 »

We're not even getting as far as sending data; it gets as far as sending SYN, then we never get the ACK back - the socket is never connected.

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
Administrator

« JGO Overlord »


Medals: 1369
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #3 - Posted 2014-11-11 19:15:59 »

Are these plain Old IO Sockets? NIO? URL.openStream()? Presumably no SSL. Does the serversocket still receive an .accept(), after which no data is received?  What happens under stress? (try 10 conn / sec) Do you use thread pools backed by ExecutorService? Does it work reliably when the server is hosted on localhost / somewhere in the LAN? Is your client on a wifi network? Is your clients' uplink saturated, or your servers' downlink? Do you have the same problems when connecting through other ISPs? (think server<->server)

Can you host a ping-like tcp service on port 25000 (or another port, as not to ruin your dev-efforts) and let the community test it for a bit?

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline princec

« JGO Spiffy Duke »


Medals: 1107
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #4 - Posted 2014-11-11 20:30:53 »

Server code is thus:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
private void run() {
   final AtomicBoolean shutdown = new AtomicBoolean();

   while (!shutdown.get()) {
      Socket socket = null;
      try {
         socket = serverSocket.accept();
      } catch (IOException e) {
         warning("Failed to listen", e);
      } catch (Throwable t) {
         shutdown.set(true);
         severe("Unexpected trouble", t);
      }
   }
}

I've completely removed all the actual processing, executor, SSL, etc. That's literally all it is doing now: accepting sockets.

Client code is:
1  
2  
3  
4  
socket = socketFactory.createSocket();
SocketAddress address = new InetSocketAddress(host, port);
socket.connect(address, timeout);
socket.close();

That is, I simply connect (doesn't matter what timeout value I use) and then correctly close the socket. And then I hit that code every 250ms. It works 95% of the time, then randomly, it'll get a connect timed out. No exceptions are logged on the server nor in the server's firewall. I can get the timeout immediately upon starting, or after a few tens of attempts. I can run flat out (1 call every 250ms or so is as fast as it seems to manage) or I can run it once every 10 seconds... same happens.

Cas Smiley

Offline Riven
Administrator

« JGO Overlord »


Medals: 1369
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #5 - Posted 2014-11-11 20:36:06 »

That snippet you posted will run out of serverside file-handles pretty quickly Tongue

Can you 'deploy' this online, tell us the port:addr, and let us do some poking? I can host a similar service on JGO's VPS, so we can compare.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline princec

« JGO Spiffy Duke »


Medals: 1107
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #6 - Posted 2014-11-11 20:38:44 »

Some answers to your other questions...

this is plain old sockets, no other code than that which you see there (I whittled it back to the bare code and behold, it still occurs!). No wifi involved, bugger all bandwidth. Also occurs if I hit port 80 instead (Apache) so I think I can safely discount the Java bit of the server and iptables from any wrongdoing.

I've opened port 25000 to all (code is similar to as you see there - all you can do is close the socket, it won't otherwise respond in any meaningful way). See if you can replicate the problem.

Cas Smiley

Offline CopyableCougar4
« Reply #7 - Posted 2014-11-11 20:43:33 »

This may or may not be the issue as I am by all definitions a programming newbie. However, I found a stackoverflow post with the same issue.
The top-rated comment describes the issue as such: The socket will timeout if no data arrives within the timeout period.

Post: http://stackoverflow.com/questions/21603629/serversocket-accept-throwing-sockettimeoutexception-with-null-message
I could be quite wrong, but I thought I should post the link Smiley

CopyableCougar4

Edit: similar findings @ http://examples.javacodegeeks.com/core-java/net/sockettimeoutexception/java-net-sockettimeoutexception-how-to-solve-sockettimeoutexception/

Either wandering the forum or programming. Most likely the latter Smiley

Github: http://github.com/CopyableCougar4
Offline princec

« JGO Spiffy Duke »


Medals: 1107
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #8 - Posted 2014-11-11 20:44:55 »

No, it's not that Smiley

Cas Smiley

Offline Riven
Administrator

« JGO Overlord »


Medals: 1369
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #9 - Posted 2014-11-11 20:50:25 »

The following currently is running on java-gaming.org:25000

My client (running at 2Hz) never has I/O trouble when running this code.

Server.java
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
   public static void main(String[] args) {
      ServerSocket ss = null;

      while (true) {
         if (ss == null) {
            try {
               ss = new ServerSocket(25000);
            } catch (IOException e) {
               e.printStackTrace();
               sleep(1000);
               ss = null;
               continue;
            }
         }

         try {
            Socket s = ss.accept();
            System.out.println("accepted[" + s + "].closed");
            s.close();
         } catch (IOException e) {
            e.printStackTrace();
            sleep(1000);
            ss = null;
         }
      }
   }

   private static void sleep(int ms) {
      try {
         Thread.sleep(ms);
      } catch (InterruptedException exc) {
         // meh
      }
   }
}


Client.java
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;

public class Client {
   public static void main(String[] args) {
      final String host = "java-gaming.org";
      final int port = 25000;
      final int timeout = 5000;

      while (true) {
         try {
            Socket socket = new Socket();
            SocketAddress address = new InetSocketAddress(host, port);
            socket.connect(address, timeout);
            socket.close();
         } catch (IOException e) {
            e.printStackTrace();
         }

         sleep(500);
      }
   }

   private static void sleep(int ms) {
      try {
         Thread.sleep(ms);
      } catch (InterruptedException exc) {
         // meh
      }
   }
}

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
Administrator

« JGO Overlord »


Medals: 1369
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #10 - Posted 2014-11-11 20:58:01 »

puppygames.net:25000 is rock solid too.

I'm pretty certain the trouble is with your ISP, BT (it used to be crappy, back in the day) or your home network, fwiw.



The last unknown is your mystery socketFactory that may be configured... oddly.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline princec

« JGO Spiffy Duke »


Medals: 1107
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #11 - Posted 2014-11-11 21:25:05 »

hmm I'm on PlusNet (been on PlusNet for the entire time I've lived here). I wonder what they could be doing wrong.
I'll just check I get similar results from java-gaming...

<edit>
Ok, JGO is rock solid for me too. And vastly faster: 30ms response or less compared to 250ms from puppygames!

Would you mind altering the server code so that it doesn't close the socket?

Cas Smiley

Offline Riven
Administrator

« JGO Overlord »


Medals: 1369
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #12 - Posted 2014-11-11 21:37:14 »

Well, I can't let the server run out of file handles. that can screw up the OS quite badly, as every single service/process will start to fail in spectacular ways. So... what can I do for you instead? A ping/pong-like service?

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline princec

« JGO Spiffy Duke »


Medals: 1107
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #13 - Posted 2014-11-11 21:39:32 »

Don't worry, I'm closing the sockets immediately from the client end and I'll only run the test for a few seconds... should survive?

(Or stick in a max count and then abort the process after say 1000)

Cas Smiley

Offline Riven
Administrator

« JGO Overlord »


Medals: 1369
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #14 - Posted 2014-11-11 21:44:57 »

Deployed:

Server.java
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;

public class Server {
   public static void main(String[] args) {
      ServerSocket ss = null;

      List<Socket> open = new ArrayList<>();

      while (true) {
         if (ss == null) {
            try {
               ss = new ServerSocket(25000);
            } catch (IOException e) {
               e.printStackTrace();
               sleep(1000);
               ss = null;
               continue;
            }
         }

         try {
            Socket s = ss.accept();
            open.add(s);
            System.out.println("accepted[" + s + "] / " + open.size());
         } catch (IOException e) {
            e.printStackTrace();
            sleep(1000);
            ss = null;
         }

         while (open.size() > 50) {
            try {
               open.remove(0).close();
            } catch (IOException e) {
               e.printStackTrace();
            }
         }
      }
   }

   private static void sleep(int ms) {
      try {
         Thread.sleep(ms);
      } catch (InterruptedException exc) {
         // meh
      }
   }
}

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline princec

« JGO Spiffy Duke »


Medals: 1107
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #15 - Posted 2014-11-11 21:49:46 »

Hmm, well that worked perfectly too on JGO. I'll try that on puppygames.

Cas Smiley

Offline Riven
Administrator

« JGO Overlord »


Medals: 1369
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #16 - Posted 2014-11-11 21:52:52 »

Linode... given they dropped the price of their low-end VPS from $20 to $10 / month, there's no reason not to make the switch. Dirt cheap, can't break it (easily). It just rocks. Pointing

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline princec

« JGO Spiffy Duke »


Medals: 1107
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #17 - Posted 2014-11-11 21:54:51 »

Think I may migrate to Linode at some point in the near future.

Running that exact code on puppygames.net:25000 now - and it fails almost instantly here with connect timed out etc.  How about when you try connecting puppygames?

Cas Smiley

Offline Riven
Administrator

« JGO Overlord »


Medals: 1369
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #18 - Posted 2014-11-11 21:56:23 »

As said before, puppygames.net:25000 was (and to this very moment is!) equally stable for me, just some hefty (atlantic ocean induced) latency.

Why are you using a SocketFactory, and how is it configured?

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline princec

« JGO Spiffy Duke »


Medals: 1107
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #19 - Posted 2014-11-11 22:01:45 »

Right then... so what does this tell us.

Firstly, that it's not puppygames.net: it works fine for you
Secondly, that it's not my server code: your code has the same problems for me and also works fine for you
Thirdly, that it's not my machine (also verified problem exists with laptop too btw): I can run against JGO and the client is fine
Fourthly, that it's not the client code: as I can run against JGO without problems
Fifthly, that it's not my ISP: as I can run against JGO without problems
Sixthly, that the port number makes no difference: happens to port 80 as well
Seventhly, that the rate makes no difference: happens at full pelt or at 1 every 10 seconds

It seems to only occur between my computer and puppygames.net.

Sorta running out of options here.

Cas Smiley

Offline princec

« JGO Spiffy Duke »


Medals: 1107
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #20 - Posted 2014-11-11 22:03:22 »

Just the default socket factory.

Also, your "server" code runs fine on JGO, and exhibits exactly the same behaviour when run on puppygames.net (ie. failure) and it does no socket configuration.

Cas Smiley

Offline Riven
Administrator

« JGO Overlord »


Medals: 1369
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #21 - Posted 2014-11-11 22:03:54 »

Fifthly, that it's not my ISP: as I can run against JGO without problems

Your ISP routes (and mangles?) your traffic.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline princec

« JGO Spiffy Duke »


Medals: 1107
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #22 - Posted 2014-11-11 22:04:14 »

Fifthly, that it's not my ISP: as I can run against JGO without problems

Your ISP routes (and mangles) your traffic.
This is possible and one of the few tentative options left... but that would mean that it's only doing this between me and puppygames.net but not me and JGO.

Cas Smiley

Offline Riven
Administrator

« JGO Overlord »


Medals: 1369
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #23 - Posted 2014-11-11 22:06:42 »

Indeed. It's not uncommon for ISPs to route badly. I get mails from people that can ping to the IP address of java-gaming.org, but cannot connect to port 80. A few weeks later they can, and all is well. Then it starts all over again... sometimes they use proxies to get in, to workaround their crappy ISPs.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline princec

« JGO Spiffy Duke »


Medals: 1107
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #24 - Posted 2014-11-11 22:06:49 »

Here's the tracert:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
Tracing route to puppygames.net [184.106.147.224]
over a maximum of 30 hops:

  1     5 ms     2 ms     2 ms  srp527w [192.168.15.1]
  2     *        *        *     Request timed out.
  3    30 ms    30 ms    28 ms  lo0-central10.pcl-ag03.plus.net [195.166.128.184]
  4    26 ms    29 ms    27 ms  link-a-central10.pcl-gw01.plus.net [212.159.2.168]
  5    26 ms    29 ms    29 ms  xe-10-2-0.pcl-cr01.plus.net [212.159.0.200]
  6    29 ms    28 ms    30 ms  xe-11-2-0.edge3.London2.Level3.net [212.187.201.213]
  7   124 ms   127 ms   136 ms  ae-210-3610.edge1.Chicago2.Level3.net [4.69.158.229]
  8   125 ms   123 ms   124 ms  ae-210-3610.edge1.Chicago2.Level3.net [4.69.158.229]
  9   125 ms   123 ms   123 ms  4.71.248.54
 10     *        *        *     Request timed out.
 11   124 ms   124 ms   123 ms  czi1-tunnel4.ord1.rackspace.net [50.56.6.163]
 12   127 ms   127 ms   126 ms  core1-CoreB.ord1.rackspace.net [184.106.126.129]
 13   124 ms   124 ms   124 ms  aggr301a-3-core1.ord1.rackspace.net [173.203.0.177]
 14   126 ms   123 ms   123 ms  184-106-147-224.static.cloud-ips.com [184.106.147.224]


Not sure why I'm getting those timeouts.

(For comparison, JGO:)
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
 1     4 ms     3 ms     5 ms  srp527w [192.168.15.1]
 2     *        *        *     Request timed out.
 3    70 ms    36 ms    34 ms  lo0-central10.pcl-ag03.plus.net [195.166.128.184]
 4    29 ms    34 ms    28 ms  link-b-central10.pcl-gw02.plus.net [212.159.2.170]
 5    26 ms    30 ms    28 ms  xe-10-2-0.pcl-cr02.plus.net [212.159.0.202]
 6    26 ms    31 ms    32 ms  ae1.ptw-cr02.plus.net [195.166.129.2]
 7     *        *        *     Request timed out.
 8    30 ms    29 ms    29 ms  217.20.44.193
 9    31 ms    29 ms    29 ms  212.111.33.234
10    27 ms    29 ms    29 ms  li732-171.members.linode.com [85.159.215.171]


Cas Smiley

Offline Riven
Administrator

« JGO Overlord »


Medals: 1369
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #25 - Posted 2014-11-11 22:12:20 »

puppygames.net
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
 1    <1 ms    <1 ms    <1 ms  192.168.1.1
 2    20 ms    20 ms    28 ms  ............ ORLY!
 3    25 ms    25 ms    25 ms  ............ ORLY!
 4    25 ms    25 ms    25 ms  ae3.cr1-asd8.nl.euro.net [194.134.161.215]
 5    34 ms    26 ms    26 ms  ae0.br1-asd8.nl.euro.net [194.134.161.171]
 6    26 ms    26 ms    26 ms  er1.ams1.nl.above.net [80.249.208.122]
 7    26 ms    27 ms    26 ms  ae8.cr1.ams5.nl.above.net [64.125.30.205]
 8   112 ms   112 ms   129 ms  xe-0-2-0.cr2.lga5.us.above.net [64.125.27.185]
 9   129 ms   139 ms   139 ms  ae6.cr2.ord2.us.above.net [64.125.24.30]
10   123 ms   124 ms   124 ms  ae10.mpr1.ord11.us.above.net [64.125.24.110]
11   123 ms   124 ms   124 ms  ae4.mpr1.ord5.us.above.net [64.125.24.94]
12   125 ms   125 ms   124 ms  208.185.125.6.IPYX-076520-ZYO.above.net [208.185.125.6]
13   124 ms   134 ms   124 ms  10.25.0.65
14   127 ms   127 ms   127 ms  czi1-tunnel4.ord1.rackspace.net [50.56.6.163]
15   125 ms   124 ms   125 ms  core1-CoreB.ord1.rackspace.net [184.106.126.129]
16   124 ms   124 ms   124 ms  aggr301a-3-core1.ord1.rackspace.net [173.203.0.177]
17   127 ms   128 ms   127 ms  184-106-147-224.static.cloud-ips.com [184.106.147.224]


java-gaming.org
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
  1    <1 ms    <1 ms    <1 ms  192.168.1.1
  2    22 ms    20 ms    19 ms  ............ ORLY!
  3    26 ms    25 ms    31 ms  ............ ORLY!
  4    26 ms    25 ms    25 ms  ae3.cr1-asd8.nl.euro.net [194.134.161.215]
  5    27 ms    31 ms    25 ms  ae0.br1-asd8.nl.euro.net [194.134.161.171]
  6    26 ms    25 ms    26 ms  er1.ams1.nl.above.net [80.249.208.122]
  7    26 ms    26 ms    26 ms  ae14.cr1.ams10.nl.above.net [64.125.21.77]
  8    31 ms    42 ms    31 ms  ae9.mpr3.lhr3.uk.above.net [64.125.28.242]
  9    31 ms    30 ms    31 ms  ae6.mpr2.lhr3.uk.above.net [64.125.21.22]
 10    31 ms    31 ms    31 ms  94.31.35.186.t01461-01.above.net [94.31.35.186]
 11    34 ms    32 ms    31 ms  212.111.33.234
 12    39 ms    31 ms    32 ms  li732-171.members.linode.com [85.159.215.171]

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline princec

« JGO Spiffy Duke »


Medals: 1107
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #26 - Posted 2014-11-11 22:13:49 »

Right, so... the only difference I can see here is that I have to go via Level3.

Cas Smiley

Offline Riven
Administrator

« JGO Overlord »


Medals: 1369
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #27 - Posted 2014-11-11 22:20:08 »

So... once you established a TCP connection... is it stable? If so, just make N connections on N threads, and close N-1 sockets.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline princec

« JGO Spiffy Duke »


Medals: 1107
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #28 - Posted 2014-11-11 22:23:43 »

I've not got as far as to test the stability of the connections yet but if you remember from the protocol we devised, it only transmits a few bytes, reads a small response, and then shuts down, in order to handle thousands of "simultaneous" clients, so stability isn't really an issue.

I can of course work around it by simply retrying until I get a connection - which is actually what I will really do - but what is bugging me is that it fails at all at this stage, most unexpectedly. It doesn't bode well for stability. But if it's genuinely just a crazy quirk of my route from home to the server, there's nothing I'll be able to do about it anyway and continually retrying will "patch" over the deficiency. It just sucks to not know why it's failing and this sort of random crap is exactly why network programming is so pointlessly difficult  Emo

Cas Smiley

Offline Riven
Administrator

« JGO Overlord »


Medals: 1369
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #29 - Posted 2014-11-11 22:30:16 »

I've not got as far as to test the stability of the connections yet but if you remember from the protocol we devised, it only transmits a few bytes, reads a small response, and then shuts down, in order to handle thousands of "simultaneous" clients, so stability isn't really an issue.
A (few?) months ago you said you rewrote everything to SSL, and as short-lived connections are truly not a good idea with SSL, given the incredible overhead of the handshake, I presumed you rewrote the protocol to persistent connections.

Anyway, network I/O is hard, and I can know, I make the 'big' bucks in this general area. If your low level code looks clean, you're doing it wrong. Put those (self-adjusting) retry-loops behind abstraction layers and you'd be relatively fine.


Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Pages: [1] 2
  ignore  |  Print  
 
 

 
Riven (90 views)
2019-09-04 15:33:17

hadezbladez (4368 views)
2018-11-16 13:46:03

hadezbladez (1561 views)
2018-11-16 13:41:33

hadezbladez (4506 views)
2018-11-16 13:35:35

hadezbladez (878 views)
2018-11-16 13:32:03

EgonOlsen (4167 views)
2018-06-10 19:43:48

EgonOlsen (4883 views)
2018-06-10 19:43:44

EgonOlsen (2811 views)
2018-06-10 19:43:20

DesertCoockie (3717 views)
2018-05-13 18:23:11

nelsongames (4023 views)
2018-04-24 18:15:36
Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!