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

WebSocketServer doesn't accept connections over ipv6 #39331

Closed
ASavchenkov opened this issue Jun 5, 2020 · 1 comment · Fixed by #48205
Closed

WebSocketServer doesn't accept connections over ipv6 #39331

ASavchenkov opened this issue Jun 5, 2020 · 1 comment · Fixed by #48205

Comments

@ASavchenkov
Copy link

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

@Faless
Copy link
Collaborator

Faless commented Apr 26, 2021

I confirm that URL parsing is broken for literal IPv6.
In any case, ws://1234:1234:123:1234:1234:1234:1234:1234:3476 is an invalid URL.
Should be: ws://[1234:1234:123:1234:1234:1234:1234:1234]:3476 (which will work in HTML5 at least).

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

Successfully merging a pull request may close this issue.

4 participants