Photon LAN, no internet

I am trying to configure my game to work on LAN with no internet using photon. Is this possible?

I built my game and ran the exe separately which should be making the server.
Then when I run my game in unity, it just says ExcpetionOnReceive while connecting to 127.0.0.1

I my settings file, I have the following:
Self Hosted
127.0.0.1
5055
Udp
AppId [blank]

Do I need appid even for a local server? If yes, then is there any unity networking package that will work completely offline?
Or maybe if I have appid, it will work offline?

Here is the code I am using:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Network : MonoBehaviour
{

    // Use this for initialization
    void Start ()
    {
        Connect ();
    }

    void Connect()
    {
        PhotonNetwork.ConnectUsingSettings ("v001");
    }

    void OnGUI()
    {
        GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString ());
    }

    void OnJoinedLobby()
    {
        PhotonNetwork.JoinRoom ("BEAST");
    }

    void OnPhotonRandomJoinFailed()
    {
        PhotonNetwork.CreateRoom ("BEAST");
    }

    void OnJoinedRoom()
    {
        GUILayout.Label ("It WORKED!!!!!");
    }
}

PUN does not support hosting the game within some client. You always need a dedicated Photon Server for the clients to connect to. There are various pros for this approach and some cons, of course. It’s simply the way Photon works.

Photon Bolt can host the game in a Unity instance but still, you need a Photon Server for matchmaking and potentially for relay. So it’s not an alternative for pure local network (without internet connectivity).

Hosting a Photon Server is simple. Also, configuring the PUN 2 client for your your own Photon Server isn’t very hard.

1 Like

Using Photon Bolt Pro and having Photon Server running - will it be possible to have few players playing a game in LAN without ANY internet connection at any stage?

With Bolt PRO it should be possible even without the photon server (with it you can do direct connections).

Please contact us through email to get the details, as Bolt PRO licenses are handled specifically for each use case.

forgot to say the email: the official developer@photonengine.com

Thanks for the answer. I have a project that is long time in development and still in “prototype” mode, using Unity 5.6 and PUN and now there is a requirement to have it running “with” and “without” internet connection modes. So besides having possibility of “LAN only” I want to upgrade to latest Unity version and start using DOTS. And there is a problem that “Connected games” feature is “too fresh”, and Bolt is too “old” and doesn’t support it as far as I know : ) So i’m confused of what path to choose… : )

Hi guys,

I’m using the approach presented by @tobiass and it works, quite Ok.

But there is one problem - I wanted to provide a functionality to switch between cloud / LAN on my clients in a run time:

Switching to LAN:

PhotonNetwork.PhotonServerSettings.AppSettings.Server = *my LAN IP*
PhotonNetwork.PhotonServerSettings.AppSettings.Port = *my LAN port*
PhotonNetwork.PhotonServerSettings.AppSettings.FixedRegion = "";

Switching to cloud

PhotonNetwork.PhotonServerSettings.AppSettings.Server = null;
PhotonNetwork.PhotonServerSettings.AppSettings.Port = 0;
PhotonNetwork.PhotonServerSettings.AppSettings.FixedRegion = *my fixed region*;

And now where the problem happens:

  1. I start the app, by default the cloud mode is switched on, I connect to the cloud server successfully. I disconnect.
  2. I switch to LAN mode, I connect to the LAN server successfully. I disconnect.
  3. I switch back to the cloud mode and try to connect and receive an error: OperationResponse 230: ReturnCode: 32756 (). Parameters: {} Server: NameServer Address: my LAN IP:my LAN port*

So… Despite the fact I did ‘Switch to cloud’ (code above) Photon somehow still tries to connect to my LAN IP address.

Is there any way to “reset” the thing on runtime? Or maybe I’m missing something here?

BR!
Jacob

Do you disconnect before you connect again? Do you call ConnectUsingSettings()?