Skip to content

WebSocketServer doesn't accept connections over ipv6 #39331

Closed
@ASavchenkov

Description

Godot version:

3.2.1

OS/device including version:

Microsoft Windows 10 Home Version 10.0.18362 Build 18362

Issue description:

WebSocketServer and WebSocketClient fail to connect when attempting to use an ipv6 address, but connect correctly when using ipv4 addresses.

Documentation on how ipv6 interacts with Websockets in Godot is spotty, but based on PRs #26189 and #26688, I take it that ipv6 compatibility with websockets is mostly automatic.

If it is not automatic, I don't see any mention on the doc page wrt. configuring the server for this.

Steps to reproduce:

Server.cs

'
using Godot;
using System;

public class Server : Node
{

WebSocketServer server = new WebSocketServer();
int PORT = 3476;

// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
    // server.Connect("data_received", this, "_OnData");
    server.Connect("client_connected", this, "_PeerConnected");
    // server.Connect("client_disconnected", this, "_PeerDisconnected");
    server.Listen(PORT);
    GD.Print("Server Listening");
}

public void _PeerConnected(int id, String protocol = "")
{
    GD.Print("_PeerConnected: ", id);
}
public override void _Process(float delta)
{
    server.Poll();
}

}
'
ipv6Test.zip

Client.cs:

'
using Godot;
using System;

public class Client : Node
{

    WebSocketClient client = new WebSocketClient();
    string ipv4 = "ws://192.168.1.143:3476";
    string ipv6 = "ws://1234:1234:123:1234:1234:1234:1234:1234:3476";
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        client.Connect("connection_established",this, "_Connected");
        client.ConnectToUrl(ipv4);
        GD.Print("Client trying to connect");
    }

    private void _Connected(string protocol)
    {
        GD.Print("Connected");
    }

// Called every frame. 'delta' is the elapsed time since the previous frame.
    public override void _Process(float delta)
    {
        client.Poll();
    }
}

'

Minimal reproduction project:

ipv6Test.zip

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions