whirvis / JRakNet

A protocol implementation of the networking library RakNet.
http://jraknet.whirvis.com
MIT License
116 stars 39 forks source link

Server can't receive ping/packets/anything #65

Closed DefinitlyEvil closed 7 years ago

DefinitlyEvil commented 7 years ago

I am using Minecraft: Win10 (1.2.2, identifier protocol set to 137)

It didn't even call my listener!?

>[03:31:11] [WARNING] §eThis is a development build. It may contain bugs. Do not use on production.

[03:31:11] [INFO] Starting up DragonProxy, version: 0.1.0-preR1 ...
[03:31:11] [INFO] Supported version of Minecraft PC/Mac: 1.12.1
[03:31:11] [INFO] Supported version of Minecraft: Pocket/Windows 10 Edition: 1.2.2
[03:31:11] [INFO] Creating thread pool(Size:16)...
[03:31:11] [INFO] Binding on 0.0.0.0:19132 ...
[03:31:11] [INFO]  JRakNet server #-7769900956331783555: Added listener org.dragonet.proxy.network.RaknetInterface
[03:31:11] [INFO]  JRakNet server #-7769900956331783555: Added listener net.marfgamer.jraknet.server.RakNetServer
[03:31:11] [INFO]  JRakNet server #-7769900956331783555: Started on thread with name JRAKNET_SERVER_-7769900956331783555
[03:31:11] [INFO]  JRakNet server #-7769900956331783555: Set identifier to "MCPE;TEST DRAGONET SERVER;137;1.2.2;1;2;4051800298639684597;DragonProxy;Survival"
[03:31:11] [INFO] The proxy has started!
[03:31:12] [DEBUG] JRakNet server #-7769900956331783555: Created and bound bootstrap
[03:31:12] [INFO]  JRakNet server #-7769900956331783555: Started server

    @Override
    public void handlePing(ServerPing ping) {
        System.out.println("PING " + ping.getSender().toString());
    }

    @Override
    public void onClientConnect(RakNetClientSession session) {
        System.out.println("CLIENT CONNECT");
        String identifier = session.getAddress().toString();
        UpstreamSession upstream = new UpstreamSession(proxy, identifier, session, session.getAddress());
        sessions.newSession(upstream);
    }

    @Override
    public void onClientDisconnect(RakNetClientSession session, String reason) {
        System.out.println("CLIENT DISCONNECT");
        UpstreamSession upstream = sessions.getSession(session.getAddress().toString());
        if (upstream == null) {
            return;
        }
        upstream.onDisconnect(proxy.getLang().get(Lang.MESSAGE_CLIENT_DISCONNECT)); //It will handle rest of the things.
    }
whirvis commented 7 years ago

First are you using JRakNet v2.8.1 or v2.8.2? There was a bug from v2.8.0-v2.8.1 that completely broke the MinecraftIdentifier. Second of all, JRakNet is unable to work with Windows 10 due a bug on Windows 10 that causes conflicts with other servers on the same machine. Try using a different device on the same LAN network. After that, please let me know whether or not it is still not showing up in the server list :)

DefinitlyEvil commented 7 years ago

hey good afternoon! v2.8.2 latest, even tried bleeding-edge snapshot. and PMMP is working normally when using MC:Win10 to join.

DefinitlyEvil commented 7 years ago

But PMMP could work well on same machine... why?? PS: Just tested, still unable to connect using port 19100.

whirvis commented 7 years ago

Could you try connecting using a different device, and could I see your server code?

DefinitlyEvil commented 7 years ago

It's open source in DragonetMC organization.

whirvis commented 7 years ago

Yes but I need the parts of the code where you are actually using the server. I can't scour through the entire source of the project.

DefinitlyEvil commented 7 years ago

here: https://github.com/DragonetMC/DragonProxy/blob/master/proxy/src/main/java/org/dragonet/proxy/network/RaknetInterface.java

whirvis commented 7 years ago

I'm honestly not sure what's wrong, the code works for me on my machine (The code you sent me, minus the code that would not run without the rest of DragonProxy)

Once again, I will ask, have you tried using a separate device on the same LAN network?

DefinitlyEvil commented 7 years ago

@MarfGamer yep I tried, didn't work. :( unable to discover, also unable to connect directly.

PS: WAIT IT WORKS!! both on my PC and my iPhone. idk what happened. xD sry mate

DefinitlyEvil commented 7 years ago

wait, I must use my phone to send some packets(like discovery packets) to let my local PC to discover the server??

whirvis commented 7 years ago

No no no no, it would make no difference on the local PC, I wanted to see if the server still worked on a different device. If it didn't, then it was JRakNet. If it it only failed to function on the local PC, then it was not JRakNet but instead Minecraft.

DefinitlyEvil commented 7 years ago

initially, local PC can't discover the server, but after my iPhone sent some discovery packets, both platform could discover the server. xD

whirvis commented 7 years ago

That is extremely strange, I will look into that. But just to make sure, everything works on separate devices, correct?

DefinitlyEvil commented 7 years ago

@MarfGamer that's true, yep. ;) I think you shouldn't bind to broadcast address, you should only receive discovery packets from there but you listen on 0.0.0.0.