EsotericSoftware / kryonet

TCP/UDP client/server library for Java, based on Kryo
BSD 3-Clause "New" or "Revised" License
1.82k stars 419 forks source link

Discovery broken out of the box #30

Open ghost opened 10 years ago

ghost commented 10 years ago

From golgo...@gmail.com on December 29, 2012 23:19:58

What steps will reproduce the problem?

  1. Download the latest .zip
  2. Using the all jar.
  3. Just run the discovery code copy pasted from the front page of this project. First run server, then run client. The client immediately throws an exception. What is the expected output? What do you see instead? This code should work out of the Box What version of the product are you using? On what operating system? Kronet 2.20 Mac OSx 10.8 Please provide any additional information below. Immediately get this error on the client. 00:00 ERROR: [kryonet] Host discovery failed. java.io.IOException: Invalid argument at java.net.PlainDatagramSocketImpl.send(Native Method) at java.net.DatagramSocket.send(DatagramSocket.java:625) at com.esotericsoftware.kryonet.Client.broadcast(Client.java:412) at com.esotericsoftware.kryonet.Client.discoverHost(Client.java:428) at DiscoveryClient.main(DiscoveryClient.java:15) null

Original issue: http://code.google.com/p/kryonet/issues/detail?id=29

ghost commented 10 years ago

From golgo...@gmail.com on December 29, 2012 14:24:47

Ah, fixed it. You need to require ipv4 like this. System.setProperty("java.net.preferIPv4Stack" , "true");

ghost commented 10 years ago

From golgo...@gmail.com on December 29, 2012 15:21:34

This actually fails as a client in Android though, with or without that property. The stack trace is as follows.

12-29 18:07:57.619: I/System.out(8041): 00:00 ERROR: [kryonet] Host discovery failed. 12-29 18:07:57.619: I/System.out(8041): java.net.SocketException: sendto failed: ENETUNREACH (Network is unreachable) 12-29 18:07:57.619: I/System.out(8041): at libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:506) 12-29 18:07:57.619: I/System.out(8041): at libcore.io.IoBridge.sendto(IoBridge.java:475) 12-29 18:07:57.619: I/System.out(8041): at java.net.PlainDatagramSocketImpl.send(PlainDatagramSocketImpl.java:182) 12-29 18:07:57.619: I/System.out(8041): at java.net.DatagramSocket.send(DatagramSocket.java:284) 12-29 18:07:57.619: I/System.out(8041): at com.esotericsoftware.kryonet.Client.broadcast(Client.java:412) 12-29 18:07:57.619: I/System.out(8041): at com.esotericsoftware.kryonet.Client.discoverHost(Client.java:428) 12-29 18:07:57.619: I/System.out(8041): at jibo.networking.MainActivity$1.run(MainActivity.java:60)

ghost commented 10 years ago

From maximili...@gmail.com on February 26, 2013 14:20:00

I can confirm that this is broken on both Desktop and Android. Setting System.setProperty("java.net.preferIPv4Stack" , "true"); didn't help on either system. Would be awesome if you can fix this! :)

ghost commented 10 years ago

From nathan.s...@gmail.com on February 26, 2013 14:41:45

Not sure what the deal is with this. Android networking is notoriously bad...

ghost commented 10 years ago

From JedyDe...@gmail.com on February 26, 2013 15:04:29

I have the same issue.

here "doomtoo on: 22-09-12" claims to have an fix to the problem: https://groups.google.com/forum/?fromgroups=#!topic/kryonet-users/UO8B9jzV5Bo I think he is right about the issue but I'm quite a noob with .jars and can't get his fix working (I get a whole bunch of other errors due to lib related stuff) maybe one of you guys can get his fix working?

ghost commented 10 years ago

From JedyDe...@gmail.com on February 27, 2013 03:16:42

My project works now again look at this conversation:

doomtoo, on 22-09-12: https://groups.google.com/forum/?fromgroups=#!topic/kryonet-users/UO8B9jzV5Bo

ghost commented 10 years ago

From naar...@gmail.com on September 14, 2013 13:55:44

same problem, same solution (on KindleFire HD and on other Android devices)