Skip to content
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

Invalid packet received. Unabled to find requested cached node. #34676

Closed
git2013vb opened this issue Dec 29, 2019 · 22 comments
Closed

Invalid packet received. Unabled to find requested cached node. #34676

git2013vb opened this issue Dec 29, 2019 · 22 comments

Comments

@git2013vb
Copy link

git2013vb commented Dec 29, 2019

Godot version:
3.2beta4
OS/device including version:
debian 10
Issue description:

ERROR: _process_get_node: Invalid packet received. Unabled to find requested cached node.
   At: core/io/multiplayer_api.cpp:263.
ERROR: _process_packet: Invalid packet received. Requested node was not found.
   At: core/io/multiplayer_api.cpp:202.

The error happen after i use disconnect_peer(id) from server
and I try again to reconnect from client.
If I restart the client after disconnect I can reconnect with no problems
Can be related with other cache network issues already closed but I'm not sure.

As workaround I reinstance NetworkedMultiplayerENet every time i call close_connection

Steps to reproduce:
NA (ask for more info if you need)
Minimal reproduction project:
Is a client server approach in same computer for now.

@Faless
Copy link
Collaborator

Faless commented Dec 29, 2019

@git2013vb can you provide a minimum reproduction project?
(similar issue was fixed in #33069 , needs more info)

@git2013vb
Copy link
Author

git2013vb commented Dec 29, 2019

bug_cache_server.zip
tutorialclient.zip

Here :)
I used 2 projects one as server and one as client ( I don't like to mix things :))
But I quite confident Its same cache that still remain in memory or is not accessible , I'm guessing because If I'm forced to restart NetworkMultiplayerENet to have a clean start seems to me something do not the right cleaning/initialization when I use "close_connection". Ciao.

ps.: I give you an hint: if you don't use rpc it work like a charm...

@Faless
Copy link
Collaborator

Faless commented Dec 30, 2019

Oh, I see, the problem is that you re-assign the network_peer in the client with the same peer every time.
This cause the multiplayer API to not be reset (see #25010).
To fix it, simply use a new NetworkedMultiplayerENet every time, or set the network peer explicitly to null before setting the new peer:

func _on_JoinServer_pressed():
	host = NetworkedMultiplayerENet.new() # New object every time
	var ip = "127.0.0.1"
	host.create_client(ip, PORT)
	get_tree().set_network_peer(host)

or:

func _on_JoinServer_pressed():
	var ip = "127.0.0.1"
	host.create_client(ip, PORT)
	get_tree().set_network_peer(null) # Force reset
	get_tree().set_network_peer(host)

In general, setting the network_peer to the same value it already has, will result in a no-op.
This is done to avoid problem related to the fact that the following GDScript code:

multiplayer.network_peer.refuse_new_connections = false

Will cause first refuse_new_connections to be set on the network peer, then network_peer to be set on multiplayer, potentially causing reset.

@git2013vb
Copy link
Author

git2013vb commented Dec 30, 2019

I don't understand. When you say "the problem is that you re-assign the network_peer in the client with the same peer every time" mean is the wrong approach? If is wrong (I saw it in docs) can explain me how have to be implemented? My goal is to connect to the server when I need - even when I disconnect using:

func _on_Button_pressed():
	host.close_connection()

Why you said "every time"? Of course I will use it when I need to connect with server.
What the use of "close_connection"? I was expecting to work normally like if you "close" the you can "reopen" it again
Your explanation confuse me.

@Faless
Copy link
Collaborator

Faless commented Dec 31, 2019

can explain me how have to be implemented?

I posted the code above....

in any case there are various demos here you can use:

https://github.com/godotengine/godot-demo-projects/tree/master/networking

Having had a closer look, it seems related to the fact that close_connection do not emit the disconnect signal. This was probably desired initially because close_connection was not exposed to GDScript. This willl likely need fix in the future but so close to a release might not be the best time to do that.

@PiGuyTheCoolGuy
Copy link

I am having a very similar problem with a current project.
I have this code attached to a button no the server:
extends Button

func _on_buttonSendData_pressed():
print("Sending data to client")
var textToSend = "test"
get_tree().multiplayer.send_bytes(textToSend.to_ascii())
print("sending: " + textToSend)
On the client, i get this the same error message
I would really appreciate any help i could get, thanks

@Faless
Copy link
Collaborator

Faless commented May 31, 2020

@PiGuyTheCoolGuy can you provide a minimal reproduction project?

@WolfgangSenff
Copy link
Contributor

@Faless - has this been fixed? Seems like it should have been in/with #33069, though maybe I'm misunderstanding.

@nongvantinh
Copy link
Contributor

`

[Export] public bool ServerBuild = false;
[Export] public string ServerAddress = "127.0.0.1";
[Export] public int ServerPort = 24245, MaxClients = 100 * 12;

[Export] public PackedScene CharacterScene = null;

private Dictionary<int, Node> entities = new Dictionary<int, Node>();
public override void _Ready()
{
    GetTree().Connect("network_peer_connected", this, nameof(OnPeerConnected));
    GetTree().Connect("network_peer_disconnected", this, nameof(OnPeerDisconnected));
    GetTree().Connect("connected_to_server", this, nameof(OnConnectedToServer));
    GetTree().Connect("connection_failed", this, nameof(OnConnectionFailed));
    GetTree().Connect("server_disconnected", this, nameof(OnServerDisconnected));

    InitNetwork();
}

private void InitNetwork()
{
    if (ServerBuild)
    {
        var networkPeer = new NetworkedMultiplayerENet();
        networkPeer.CompressionMode = NetworkedMultiplayerENet.CompressionModeEnum.RangeCoder;
        Error err = networkPeer.CreateServer(ServerPort, MaxClients);
        if (err != Error.Ok)
        {
            GD.Print(err);
            return;
        }

        GetTree().NetworkPeer = networkPeer;
        // Server always has id = 1.
        GD.Print($"Server is running on: {ServerAddress}:{ServerPort} with {MaxClients} max client.");
    }
    else
    {
        var networkPeer = new NetworkedMultiplayerENet();
        networkPeer.CompressionMode = NetworkedMultiplayerENet.CompressionModeEnum.RangeCoder;
        Error err = networkPeer.CreateClient(ServerAddress, ServerPort);
        if (err != Error.Ok)
        {
            GD.Print(err);
            return;
        }

        GetTree().NetworkPeer = networkPeer;
        GD.Print($"Client is running.");
    }
}

private void OnPeerConnected(int peerId)
{
    // Ignore server connected signal.
    if (peerId == 1)
        return;

    GD.Print($"{peerId} has connected.");
    if (GetTree().IsNetworkServer())
    {
        // Send all client in scene to new connected client.
        foreach (var other in entities.Keys)
            RpcId(peerId, nameof(SyncWithServer), other);

        // Send new client to all.
        Rpc(nameof(OnClientConnected), peerId);
    }
}

[RemoteSync]
private void OnClientConnected(int peerId)
{
    var character = CharacterScene.Instance<Character>();
    character.Name = peerId.ToString();
    character.SetNetworkMaster(peerId);
    entities.Add(peerId, character);
    AddChild(character);
}

[Remote]
private void SyncWithServer(int peerId)
{
    var character = CharacterScene.Instance<Character>();
    character.Name = peerId.ToString();
    character.SetNetworkMaster(peerId);
    entities.Add(peerId, character);
    AddChild(character);
}

private void OnPeerDisconnected(int peerId)
{
    GD.Print($"{peerId} has disconnected.");
    if (entities.TryGetValue(peerId, out Node entity))
    {
        entity.QueueFree();
        entities.Remove(peerId);
    }
}

`

With the given code I don't see any problem, but when running the game I received this error four times and then run as expected.
I believe the already connected client trying to sync their state with this newly connected client, but in the newly connected client, it haven't instantiate Character yet, and causes problem.
ClientServerEnet.zip

@GitMuslim
Copy link

@Faless thank you so much man

i was getting a similar issue

ERROR: _process_get_node: Condition "!F" is true. Returned: __null
At: core/io/multiplayer_api.cpp:269.
ERROR: _process_packet: Condition "node == __null" is true.
At: core/io/multiplayer_api.cpp:208.

network.set_peer(null) fixed it

@git2013vb
Copy link
Author

git2013vb commented Jan 30, 2022

@Calinou
Hi, any ETA about this issue?
I'm stuck with it since then and I need it because my login system (client-server) doesn't work properly with this issue :)
Thanks a lot :)

I still have it in v3.5.beta1.mono.official [b9b23d2]

ERROR: Invalid packet received. Unabled to find requested cached node.
   at: _process_get_node (core/io/multiplayer_api.cpp:260)
ERROR: Invalid packet received. Requested node was not found.
   at: _process_packet (core/io/multiplayer_api.cpp:203)

@Calinou
Copy link
Member

Calinou commented Jan 30, 2022

Hi, any ETA about this issue?

There is no ETA about fixing this issue, as nobody knows how to fix it yet.

@git2013vb
Copy link
Author

git2013vb commented Feb 1, 2022

Hi, any ETA about this issue?

There is no ETA about fixing this issue, as nobody knows how to fix it yet.

I'm using C# atm. Ill follow @Faless suggestion if I can resolve it in as workaround the meantime.

Edit.: In my case, setting NetworkPeer to null (force reset) - CustomMultiplayer.NetworkPeer = null; //* force reset , It work. (Finally :) )

@Calinou From my side this issue it can be closed.

Thanks @Faless & @Calinou :)

@git2013vb
Copy link
Author

@Calinou , @Faless

Tell me if I'm wrong :)

There is a downside to reset the connection each time I have to communicate between two points as suggested @Faless :

The more common case is when I define a player in my client that Ill give it the ID (that come free) got from the connection.

If I have to use other rpc with I cannot use the same ID any more. So I have to think another way to set a immutable ID.

It make sense?

Thanks

@Faless
Copy link
Collaborator

Faless commented Feb 4, 2022

I never suggested resetting the connection each time you want to communicate, I suggested resetting the network peer when you want to disconnect or reconnect.

@git2013vb
Copy link
Author

I never suggested resetting the connection each time you want to communicate, I suggested resetting the network peer when you want to disconnect or reconnect.

Thanks for you answer.

Obviously I'm not familiar of what happen under the hood :)

So you saying setting set_network_peer to null I will not lose the ID? That's great.
Thanks.

@daveime68
Copy link

To fix it, simply use a new NetworkedMultiplayerENet every time, or set the network peer explicitly to null before setting the new peer:

Thank you, saved me a lot of headaches here. I wish this kind of issue was explicitly documented on the page.

@git2013vb
Copy link
Author

git2013vb commented Mar 19, 2022

To fix it, simply use a new NetworkedMultiplayerENet every time, or set the network peer explicitly to null before setting the new peer:

Thank you, saved me a lot of headaches here. I wish this kind of issue was explicitly documented on the page.

That's up to developer who make features to be willing to share their effort in order to share knowledge.

But not everyone have this kind of mindset.

The majority of developer think they have done the job just to create a new feature .
If they know how it work mean every body knows. Or just they don't care enough.

Maybe they expect something in return to be able to share (money). They think 1/2 job is better than nothing, or they say they have not enough time to document what they did either way that define a mediocre persona in my point of view.

Not someone who really care about others. Sorry for my rant. But is what I think and I don't like to say lies.

Thanks anyway

“With great power comes great responsibility.” – Spiderman

85fbb3ba0bbd8223fe83f2300ce361b8

@Calinou
Copy link
Member

Calinou commented Mar 19, 2022

Remember that Godot's documentation is open to contributions. The best way to fix this kind of issues is to work on it yourself 🙂

@git2013vb
Copy link
Author

Remember that Godot's documentation is open to contributions. The best way to fix this kind of issues is to work on it yourself slightly_smiling_face

I can't fix all people mistakes. Even if I want to do it is a impossible task, I'm alone against everyone else. The best think I can do is to complete my tasks at best I can do. Other have to take their responsibilities. Saying "I don't care , someone else will fix this if he need" is something than do not exist in my mindset. Sorry :)

Godot is open to "contribution" is an excuse to who do an half job. This is my opinion.

Am I strictly? Yes, of course, even more with myself.

Thanks

@akien-mga
Copy link
Member

@git2013vb I would ask you not to make demands like this for contributors. Most contributors work on their free time, and if you're not satisfied with their work, that doesn't give you a right to demand that they do more work.

Feedback is welcome, pointing out missing documentation is welcome, but bossing people around is not. If the feature is too undocumented to be useful to you, you can simply not use it until contributors get to document it better.

And the talk about money is uncalled for and completely off topic.

@git2013vb
Copy link
Author

git2013vb commented Mar 20, 2022

@akien-mga

No problem at all. I understand. I cannot write what I think here in your space.

Don't worry. I'm this first one who follow the rules set in places where I go.

I take the liberty of posting a link but feel free to delete it - or this entire post - if you think is not relevant/unsound.

Personally I think it is because when a open source project receive donation it became like a business model the it can follow certain kind of best practices.

Here the link: https://opensource.com/business/15/6/documentation-dilemma

Than you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants