Untiy Netcode For GameObject unable to connect to remote server

375 views Asked by At

I am recently trying out the new unity networking solution which is netcode for gameobjects . In Unity using netcode for gameobjects i tried making a simple game which consist of a server and clients connecting to the server. I was able to make a simple game where my server was listening on "0.0.0.0:55000" and my clients were able to connect and send RPCs.So, for now everything was going fine and everthing worked fine in my local machine.

So, now i decided to run my unity game server in remote server and try to connect from my local machine.But , i was not able to connect to the remote server. I tried many things but failed to connect to my remote hosted server.

So, i would like to give you information about my server setup. So, i am using a "AWS EC2 instance Amazon Linux Server" for my game server. I have build a "dedicated server build for linux platform" from my unity editor as a X86 file , and i have transfered all the files to my aws server using FileZilla .

Then , i tried running my server which works fine . It was running fine which i confirmed by checking all of my network ports and connections data using "netstat" command on my amazon linux server. I used the command "netstat -ltu -pt" and i was able to see the name of my unity game server running and listening on TCP "0.0.0.0:55000". Screenshot of my amazon linux serevr netstat output

I also , allowed inbound TCP request on PORT "55000" from any source on my server by using the security settings on aws. Screenshot of my allowed inbound connections on my aws server

But, when i try to connect to my server form my local machine it fails to connect for some reason.

So,** PLS HELP ME ....WHY CAN'T I CANNOR CONNECT TO MY SERVER ???????????**

The first thing i wanted to confirm was that , is my remote server accessible from anywhere or not ?

SO, i did telnet "ipaddress of remote server" "55000" , from my local windows machine from my command prompt and i was able to confirm that my ports are open because i didnot get any "failed to connect to the server" messages.

I also tried doing a http post request on my remote server using POSTMAN , and i was able to get a message on the server, the message was a courrrpt message which i expected since i tried doing a http post request to my game server which does not handle any htttp requests.

This is the message i recieved on my game server console " The message header is corrupted and for security reasons connection will be terminated".

From the above experiements that i did i was able to confirm that my remote server port is open and can be accessed by anyone .

But still i am unable to connect to my remote unity game server hosted on AWS from my local windows machine ..

I am totally clueless what to do now .....pls give me solutions

2

There are 2 answers

1
Sekhar JD On

Thank you everyone for answering i have found my answer.

The problem was that i have opened my TCP port on 55000 but did not opened my UDP port on 55000 in my AWS EC2 amazon linux server security group settings for inbound rules.

And ,if you are wondering how did i figure out that was the problem then, i used WIreshark to capture all my network data on my local winodws machine and i filtered the captued data using "ip.dst == " in the wirshark dashboard . ANd then i noticed that all the packets that was been sent to my remote server was been done on UDP and not in TCP on port 55000. So , i changed my aws security group settings to allow UDP inbound traffic on port 55000 and it solved the problem. My wireshark dashboard screenshot

2
Yash Chakravarty On

It seems like you've done a thorough investigation, and it's good that you've verified the accessibility of your AWS server by using telnet and making HTTP requests.

Here are some additional steps and considerations that might help you troubleshoot and identify the issue:

Firewall Configuration on AWS:

Double-check the security group settings on your AWS EC2 instance. Ensure that the inbound rules allow traffic on port 55000. Confirm that the outbound rules on your AWS EC2 instance are not blocking the traffic. Check Unity Networking Settings:

Confirm that your Unity game server is configured to listen on all network interfaces (0.0.0.0) rather than just localhost (127.0.0.1). Verify that your Unity networking code is correctly binding to the correct IP and port. Firewall on Local Machine:

Check if there's a local firewall on your Windows machine that may be blocking outbound connections to your AWS server on port 55000. Network Address Translation (NAT):

If your AWS EC2 instance is behind a NAT gateway, ensure that the necessary ports are forwarded correctly. Public IP vs Private IP:

Ensure you are using the public IP address of your AWS instance when trying to connect from your local machine. AWS instances have both private and public IP addresses. Unity Remote Access Testing:

Try running a simple Unity server on your local machine and see if you can connect to it from your Windows machine. This can help determine if the issue is specific to the AWS setup or a more general networking issue. Check Unity Logs:

Look at the logs generated by your Unity game server for any error messages or warnings that might indicate the source of the problem. Network Monitoring Tools:

Consider using network monitoring tools like Wireshark to capture and analyze the network traffic between your local machine and the AWS server. This can help identify if the connection attempts are reaching the server and if there are any issues with the communication. AWS EC2 Instance Logs:

Check the logs on your AWS EC2 instance for any error messages or warnings related to network connections. You can find these logs in /var/log.