I can't connect to my Photon server - PUN

Hello,

I created a PUN server on my computer (self-hosted), but i can’t connect to this server.
I have a static IP and the port 5055 is opened (for UDP).
My antivirus/firewall is not blocked the port.

This is the error in the Unity console: Screenshot by Lightshot
If i run the test client (LoadBalancing), i have this result: Screenshot by Lightshot
What is written on russia language on the screenshot: “Error trying to receive. Exception: System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host.”.

Why i can’t connect? Please help :slight_smile:

Best regards,
Gleb.

I think we solved this via mail.
In essence: You have to setup the IP for the Game Server in the Photon Control tool. By default, the Master Server will forward clients to the “localhost” IP but if the client runs in the net on another machine, that’s not working for the client.

See:
https://doc.photonengine.com/en-us/onpremise/current/getting-started/photon-server-in-5min

I have the same issue with the latest Photon Control: 4.0.28.2962. I have same exact code running from two Unity editors on two machines in the same local N/W. One of the machines is running PhotonControl with a static IP.

The first client client creates the room and becomes the master client, and the second client gets stuck at joining the room. does not matter if the first client from the same machine as Photon Server or the other machine? The fact I am able to make either of the machines the master client, confirms me that there are no port issues. I am not sure why the second client joining the room is kicked out?

Now when I point these two clients with no code changes to point to the Photon cloud, they join the same room with out an issues. So no issues with the code and Ports: 5055 blocked by firewall or antivirus.

I have followed all the steps mentioned in the above link: https://doc.photonengine.com/en-us/onpremise/current/getting-started/photon-server-in-5min

The local Logs by “Bare Trail” doe not do huge favor as it does not seems to spit any error, the closest thing I was able to capture while running the demo Asteroids scene was: *“Join failed: UserID not set, checkUserIdOnJoin=true expects a UserId”.*

Any pointers on how to debug this will really help. Thanks.

I have an update, the issues is that the latest PUN 2.0 unity client is not working with OnPrem Server v_4.0.28.2962. I downgraded the PUN Unity client to older version 1.92, and it is working with out any issues with ports or firewalls so far, as I am testing this simulation from Unity editor

In theory, the PUN 2 clients should work with the Self Hosted Server as well. Maybe the setup was botched. Follow this
Configuration For Self Hosted Photon.
In doubt, enable the Support Logger in the clients and send the logs to: developer@photonengine.com.

I got an update that there might be a bugs with the way UserID getting setup on the OnPrem servercode and the new PUN SDK. For now I am switching back to the 1.9.2 version and look into upgrading in the future.

Hi @achitimalli165196 ,

Thank you for choosing Photon!

Make sure to set a unique UserId per player from the client (PhotonNetwork.UserId = userId;) before connecting.
The UserId could be simply a GUID: PhotonNetwork.UserId = Guid.NewGuid().ToString();.
In PUN Classic, if the client does not set a UserId, the UserId will be set to the Nickname before connecting. In PUN2 this is no longer the case.

When I run Photon Control, the option for “Start as application” is disabled. Am I missing something for Photon Server v4?

Hi @AllFatherGray_1

This probably means that the server is already running, maybe it’s already started as an application or as a service.
Or maybe there is something wrong with the configuration.

Also, make sure to not move the server files or delete them manually.