0 votes
func _ready():
    ws = WebSocketClient.new()
    ws.connect("connection_established", self, "_connection_established")
    ws.connect("connection_closed", self, "_connection_closed")
    ws.connect("connection_error", self, "_connection_error")

    var url = "ws://localhost:8080"
    print("Connecting to " + url)
    ws.connect_to_url(url)

func _connection_established(protocol):
    print("Connection Established With Protocol: ", protocol)

func _connection_closed():
    print("Connection Closed")

func _connection_error():
    print("Connection Error")

func _process(delta):
    if ws.get_connection_status() == ws.CONNECTION_CONNECTING || ws.get_connection_status() == ws.CONNECTION_CONNECTED:
        ws.poll()

it is okay when i connect to local node server.
but when i deploy on heroku, and turn the URL var into "https://gdwebsocketdemo.herokuapp.com/"
it come out with an error:

The argument 'delta' is never used in the function 'process'
getaddrinfo failed! Cannot resolve hostname
Condition '!addr.is
invalid()' is true. returned: ERRINVALIDPARAMETER

since i don't have a fully understanding on websocketclient usage. what might be the issue. thank you.

btw. it's an examples of gd-com-utils provided by Salsa2K.
https://www.npmjs.com/package/@gd-com/utils/v/1.0.0
https://github.com/gd-com/utils

in Engine by (12 points)

1 Answer

+1 vote

Hi there,
I know it is a late reply, but in case anyone else is looking for this:

You need to specify a port in the url such as : "https://gdwebsocketdemo.herokuapp.com:8080"

by (16 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.