-
Notifications
You must be signed in to change notification settings - Fork 416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kryonet disconnects just after connecting #35
Comments
From twazerty on September 09, 2013 12:36:43 I have the same problem when I only connect via TCP (Server listens on TCP and UDP). When I connect with TCP and UDP in de client everything works ok. |
From [email protected] on November 06, 2013 01:46:15 I also had this problem. |
I got the same problem. Is there a solution for this problem? |
I am also having this problem, any solution found? @Kronos87 |
See discussion here: |
Hey guys, just wanted to add that we're seeing this behavior in the development of an Android app that utilizes Kryonet - when connecting the client only via TCP, it establishes a connection, but any sendTCP calls don't result in the server receiving any data. The server's connected() is not invoked, and the client shortly disconnects after not receiving any response from the server. We are using discoverHost as the basis for the host address the client uses. If we update the client connect() call to include the UDP port, everything works as expected. The workaround seems to be having the client specify both TCP and UDP ports in connect(), though I do not know the specifics as to what is causing this internally within the Kryonet source (we're using the latest 2.21-all jar in our project). Just wanted to add our experience, and that the above workaround appears to be working in our case - I hope this helps. |
I experience the same problem and the same solution. You have to specify the UDP and TCP port. Please fix that problem! |
No one shows an executable example and all the KryoNet tests pass, so I assume your code is wrong. Guessing at your problem is usually a waste of time, but probably you start a server that expects both a TCP and UDP connection from a client. |
I'll prepare an example next week. |
If your server has a TCP and UDP port, your clients must also. You can run a separate server for UDP discovery. |
Also,when having both ports fail, all of your classes that you register with Kryo, should have an empty constructor inside them, fixed the problem for me. Might be worth putting this into the readme, aswell :) , otherwize this thing is 👍 |
I'm sorry I forget this issue here. @NathanSweet Yes, that was the solution! I needed to specify both ports for the clients, too! Thanks :) |
hit the same issue. my problem was that I registered the UUID class which doesn't provide a public default constructor. replacing it solved the problem for me |
@breskeby Exact same problem here. I'd thought I'd added default constructors to all registered classes, but there was one without. Adding a default constructor fixed it immediately. |
I agree with @MarkSill, I faced the same problem yesterday and adding ALL default constructors fixed everything! Someone should spread this around. |
@Isfirs Same issue, same solution. Public default constructors need to be added to every single one. |
Sounds like two separate problems:
What error does 2 provide? It should be explicit that a zero arg constructor is needed. Does it fail silently instead? If so, are you using StdInstantiatorStrategy? Using that is not recommended (it creates objects without calling any constructor). KryoNet is due for an update to the latest Kryo, that may help. |
My problem was multi-fold... 1.) initially I was using Kotlin data class, which doesn't create empty constructor out of the box 2.) Kotlin also wraps arrays and stuff with its own primitives, so I moved the 3.) I didn't specify UDP port for the client even though I should have. 4.) I was trying to send TCP message back to the server using the |
Had the same issue. This solved it immediately. |
From [email protected] on July 07, 2013 19:02:06
What steps will reproduce the problem?
What is the expected output? What do you see instead?
[kryonet] Connection 1 connected: /127.0.0.1
[kryonet] Connection 1 disconnected.
in 12 seconds
What version of the product are you using? On what operating system?
2.20
Please provide any additional information below.
Reason and how to fixed it:
if i am keep writing lastWriteTime will bigger than the parameter "time" for method:
com.esotericsoftware.kryonet.TcpConnection.needsKeepAlive(long time);
so this will case "time - lastWriteTime" < 0 and of course made it < keepAliveMillis. That is why needsKeepAlive() will always return true, and client killed it by itself.
i fixed by adding such code in the needsKeepAlive() method and isTimedOut (long time) method, you can see details in attachment.
Hope this helpful!!
BTW your frame is great! and simple to use!!
Attachment: compare.jpg
Original issue: http://code.google.com/p/kryonet/issues/detail?id=34
The text was updated successfully, but these errors were encountered: