This action is used to start the connection process and attempt to connect to a server.

This action takes one string parameter, which is the server hostname (and optionally the port) to connect to.


If you are already connecting, this action will generate an error. To interrupt a connect attempt, you must use Connection > Disconnect action first.

If you are using Blue Client and mid-way through a LAN server scan, running this action will immediately abort the scan and start the connect as normal.

Triggered responses

If the connection is not successful, e.g. due to server being non-responsive, you will get an On error event.

If the connection succeeds but is denied by the Relay/Blue server at connect request stage, you will get Connection > On connection denied followed by Connection > On disconnect.


A UDP bug is present in Relay Server that will prevent approved connections ever completing, but this bug is fixed in Blue Server. No events will be triggered by a server having this bug, even by Blue Client.

Notes

The server hostname can be a domain or IP address, be it IPv4 or IPv6 address. IPv6 addresses should be wrapped in brackets.

If the port is not specified, Lacewing Relay's default port 6121 will be used.


Here are some examples you can connect to:

  • "server1.dark-wire.com" – only the server host name is specified, default port 6121 will be used.
  • "server2.dark-wire.com:6122" – both the server host name and an explicit port is specified, connection will occur on port 6122.
  • "82.165.218.31:6123" – an IPv4 address with port 6123.
  • "[2a02:2479:7e:cb00::1]:6121" – an IPv6 address explicitly using port 6121.


If you are hosting a server on the same machine your client application is running on, you can connect to use IP "127.0.0.1", or "localhost".

  • "127.0.0.1" – same machine as app, default port 6121 will be used.
  • "localhost" – same machine as app, default port 6121 will be used.


There are free public servers for use that you can connect to here.

Feel free to read the Security topic to secure your apps on a public server, but unless you're transmitting private information or starting to publish a game, you aren't in a danger zone yet; Blue does not access your local files without Fusion events to do so.

HTML5/UWP

In Blue Client HTML5 and UWP, you should connect to a WebSocket server, not the regular Relay server.

You can manually specify ws:// for insecure, and wss:// for secure socket.

  • "ws://server1.dark-wire.com:80/" – explicitly insecure WebSocket connection
  • "wss://server1.dark-wire.com:443/" – explicitly secure WebSocket connection
  • "server1.dark-wire.com" – which port and which WebSocket connection type to use will be guessed; see platform notes.


HTML5 Client apps must use a secure WebSocket if connecting from a https:// page.

To read more about WebSocket, read the platform notes for HTML5 or UWP.