Connect to self-hosted master server and join room (WebSocketSecure).

Options
Hi! I try to connect with WebSocketSecure protocol to my self-hosted server. (there are no problems with Photon Cloud)

I connect to self-hosted server using port 9090 (Master) and it connects to lobby without problems. But when I try to create room after this, I get exception:


This is place in code which calls this exception (NetworkingPeer.GameEnteredOnGameServer(OperationResponse operationResponse)):

This is because OperationResponse.ReturnCode == 0. (but I don't know why and what to do)

When I use port 9091 (Game) I connect and join/create room without problems. It would be ok, but using port 9091 I can't get PhotonNetwork.GetRoomsList(), can't use JoinRandomRoom() and others...

When I use Tcp protocol and connect using port 4530 (Master) it connects and joins lobby and creates room without problems. (that's what I want from wss connection)

So what do I have to change on server/client to solve this problem?

This is my SocketWebTcp.cs:


This is my PhotonServer.config WebSocketListeners:
<WebSocketListeners>
			<WebSocketListener
				IPAddress="0.0.0.0"
				Port="9090"
				DisableNagle="true"
				InactivityTimeout="10000"
				OverrideApplication="Master"
                                PolicyFile="Policy\assets\socket-policy.xml"
                                Secure = "true"
                                CertificateName = "WIN-GR1JM6PETN8"
                                UseMachineStore = "true">
			</WebSocketListener>
			
			<WebSocketListener
				IPAddress="0.0.0.0"
				Port="9091"
				DisableNagle="true"
				InactivityTimeout="10000"
				OverrideApplication="Game"
                                PolicyFile="Policy\assets\socket-policy.xml"
                                Secure = "true"
                                CertificateName = "WIN-GR1JM6PETN8"
                                UseMachineStore = "true"> 
			</WebSocketListener>			
</WebSocketListeners>
This is how I connect to server;
PhotonNetwork.ConnectUsingSettings(Version + "." + SceneManagerHelper.ActiveSceneBuildIndex);

What is the rightest way to set server/client for right wss connection? To I would connect to 9090 and get RoomList() and create/join room (in Tcp it works)
I want to repeat: it connects to lobby, but can't create/join room bcs of exception above.

Thanks a lot.

(I swear, if I solve all my problems with self-hosted server and WebSockets and PUN, I will necessarily write detailed guid of this. :#)

Answers

  • crutch12
    Options
    I solved everything. Guide will be soon :)
  • dreadlocks
    Options
    Hello, can I have the guide please I got the same problems and more!
  • crutch12
    crutch12
    edited February 2017
    Options

    Hello, can I have the guide please I got the same problems and more!

    Hi

    Sorry for late. I've just installed last pun version (v1.80) to decide this problem again and give you an answer. I use last version server (OnPremise v4.0.29.11263).

    Server Part:

    Install certificate (https://doc.photonengine.com/en-us/onpremise/v3/reference/websockets-ssl-setup)

    Open \...\Photon-OnPremise-Server-SDK_v4-0-29-11263\deploy\bin_Win64\PhotonServer.cfg

    Change WebSocket part like me (set your certificate name instead *YOUR_CER_NAME*):
    <!-- WebSocket (and Flash-Fallback) compatible listener --> <WebSocketListeners> <WebSocketListener IPAddress="0.0.0.0" Port="9090" DisableNagle="true" InactivityTimeout="10000" OverrideApplication="Master" PolicyFile="Policy\assets\socket-policy.xml" Secure = "true" StoreName = "MY" CertificateName = "*YOUR_CER_NAME*" UseMachineStore = "true"> </WebSocketListener> <WebSocketListener IPAddress="0.0.0.0" Port="9091" DisableNagle="true" InactivityTimeout="10000" OverrideApplication="Game" PolicyFile="Policy\assets\socket-policy.xml" Secure = "true" StoreName = "MY" CertificateName = "*YOUR_CER_NAME*" UseMachineStore = "true"> </WebSocketListener> </WebSocketListeners>

    Client Part:

    Find in your project class SocketWebTcp.cs

    In this class find lines:
    this.sock = new WebSocket(new Uri(ServerAddress));
    this.sock.Connect();
    
    Paste this code instead this.sock = new WebSocket(new Uri(ServerAddress));
    string serverIP = PhotonNetwork.PhotonServerSettings.ServerAddress; // ip that you set in PhotonServerSettings
    string mainPort = "9090";
    string secondPort = "9091";
    
    if (ServerAddress[0] == 'w')
    {
           Debug.Log("TRY CONNECT TO " + "wss://" + serverIP + ":" + secondPort);
           this.sock = new WebSocket(new Uri("wss://" + serverIP + ":" + secondPort));
    }
    else
    {
            Debug.Log("TRY CONNECT TO " + "wss://" + serverIP + ":" + mainPort);
            this.sock = new WebSocket(new Uri("wss://" + serverIP + ":" + mainPort));
    }
    
    That's all. After these moves your SocketWebTcp.cs has to be look like this:



    Please check it first in clear project.

    Hope this will help you.

    Bye.