Find Sessions / Join Sessions by IP address

Is it possible to connect to a server by providing an IP address and port from within game.

Im aware that this can be done via adding arguments to launcher shortcut but what about in game?

Thanks
Shiftone

2 Likes

This should help you: )

Thanks for taking the time to respond.

I had a read through that page last night and couldn’t see a way to accomplish what i was after.

Would I need to add an OnlineSubsystem module even if the user was entering a direct IP address location of the dedicated server?

1 Like

Yes you can. I just posted this response on Answers the other day. I’ll copy/paste it. (But you’ll want to use OnlineSubsystemNull and make sure LAN is checked on create session.

So 2 things that helped me accomplish MP over the web. I used a 3rd party plugin for REST Api’s called VaRest. I built out a simple node.js server to retrieve json objects posted over the internet. The beauty of using node.js here is I can easily manage an object of servers. And I can easily purge those servers after X amount of time. I hosted this app on my web server. But you could even host it on your own computer and use a dynamic dns service that the clients connect too (if your IP is dynamic).

When the host creates a new game via the menu, it will create the multiplayer session using the methods in the twitch stream. I use VaRest to POST to my API, things like host name, game name, map. The server grabs the clients IP address and appends that to the object. Next, the Join Game screen is simply a browser list. I use VaRest again here and created another API endpoint for grabbing the list of servers. When the user has selected the server they want to join. I run a simple console command “open [ip address]” and the game connects. You must open and forward port 7777 tcp/udp on the hosts router/machine. This is my temporary solution until I can implement steamworks SDK.

I started something like this a while ago its not a full system its just the foundation. You could expand on it though. All it does right now is when you click “Host” it will host a game with your Ip. But when you click join it will ask you to enter an ip. Then it will take the text you typed and send it to an append which will be added to a console command to join the game of that ip. Like i said very basic but a good stepping stone :}. But Hey! It Works!.

1: Make a Widget Blueprint and name it Multiplayer.

Host_join.png

2: Make a Host and Join Button inside that widget blueprint.

3: Rename both buttons and make a bind for both.

4: Make another new widget blueprint and name it Join.

5: Inside the Join Widget Blueprint make a Editable Text and a button.

Host_join.png

6: Rename the editable text and at the top right make it a variable.

7: Set a bind for the button under the editable text.

8: Open the graph in the Join widget blueprint and copy the picture below.

Join Widget Blueprint: (The “Ip” variable is the editable textbox") Make sure you add a space after open in the append.

Ip.png

9: go back to the Multiplayer widget blueprint and open the graph.

10: on the Host button follow below.

Host Button:

HostBtn.png

11: on the Join Button.

And that should be all you need to do. It will not work in the editor you will need to Package your project and open two versions of it on your desktop. Let me know if you have any further trouble.

You don’t need that first ‘open Level1’ just ‘open ipaddress’ command node is all you need.

And BTW it should work just fine in the editor. If you’re using your own public IP address just map it to your loopback address in the windows hosts file like so:


127.0.0.1          123.123.123.123

And like I mentioned above if you’re doing this over the internet the host needs to forward port 7777udp to their local machine. (Or whatever port you’re using)

Thank you all for the assistance on this.

What I’m trying to do here isn’t far from the examples given, I am also using VaRest to communicate with my own web server to provide server lists etc.

When hitting the play button within the editor the 2 clients are automatic connected and one client is forced into listen mode. Is there a way to stop this so I can test without having to build each time?

And also is there a way to check if the connection to server was successful when using execute command “open [ip]”?

> and one client is forced into listen mode. Is there a way to stop this so I can test without having to build each time?

I don’t follow. And I’m pretty sure one has to be a listen server or it won’t work.

> And also is there a way to check if the connection to server was successful when using execute command “open [ip]”?

If it opened the level and gamemode that would be a successful connection, no? Fire an event when that happens?

I think there was a twitch stream a while ago where they had a programmer briefly go over how to do this in blueprints, It wasn’t a detailed tutorial but he explained a lot of what he was doing it starts at about 10 minutes in.https://www.youtube.com/watch?v=4LV7KKtzKs8

Hello, when i create a session gives an error “Invalid or uninitialized OnlineSubsystem”. I read on this forum to add a line DefaultEngine.ini

[OnlineSubsystem] DefaultPlatformService=Null

but is no work.

i accomplished this for my game jam game a few months ago - GitHub - bitporters/SETUSFREE: My first UNREAL ENGINE game jam game - a mashup of Stylized Rendering + - i also have a C# asp.net website that is basically a name server

it is a simple peer to peer connect . right ?
can u use all the functionality of multiplayer session that way?

Hello guys,
I’m using a similar system for my hosting, i want to know is it possible to limit the player can join via open [IP] method,
When i create a session i set the public connections to 2 but it’s not limited and i can join to server easily !

Sorry, i’m stuck at this exact point.
I want to do a connection by direct IP (i dont want to use steam neither other sistem, i NEED ip direct connection)

I have this on the game instance blueprint. I had it previously on the game mode, but cant tell if this makes a difference or not.

Host session
​​​​​​

Join Session ( Via LAN)

Join by direct IP connection

joinbyip.png

It works on LAN, but not on Internet. Before you ask, yes i have done port forwarding.

My DefaultEngine.ini :

[OnlineSubsystem]
DefaultPlatformService=Null

I would thank any help, this is making me going crazy.

Helloooo ladys.

The port needed is 7777 UDP, not tcp like i was doing …

did it funktion by an VPN like Hamachi?

Just want to say a quick thank you for this thread its going to help me a lot :slight_smile:

Can anyone tell me if I can connect this way with friends in other countries like Australia, England, Russia, South Africa and New Zealand? I am assuming that and IP address is world wide there wont be any blocks on it or regional issues or am I wrong?

No, if your friends are behind NAT. You will need static IP address. Better buy a hosting

O.k. TY :slight_smile: