我嘗試使用安全websocket連接將我的本地Photon服務器與Unity3D WebGL構建連接時出現問題。我可以建立與websockets(不是安全的)和除了WebGL之外的任何其他環境的連接(即使在Unity的具有WebGL配置的播放模式下,當我獲得構建時,它也不會工作)。我猜這個問題與我的證書有關,但我不完全確定。我嘗試了自簽名的,而且是真正的。Photon Secure WebSocket連接在Unity WebGL
以下是錯誤:
WebSocket connection to 'wss://localhost:19091' failed: Error in connection establishment: net::ERR_INSECURE_RESPONSE
我已經嘗試過127.0.0.1而不是本地主機,試圖改變端口。
我得到了我的插座代碼光子的網站,鏈接在這裏:
https://www.photonengine.com/sdks#onpremiseunity3d
我的客戶代碼(採用光子的SocketWebTcp類)是這樣的:
using ExitGames.Client.Photon;
using UnityEngine;
public class HiveClient : IPhotonPeerListener
{
public PhotonPeer PhotonClient { get; set; }
public HiveClient() { }
public void Connect()
{
this.PhotonClient = new PhotonPeer(this, ConnectionProtocol.WebSocketSecure);
this.PhotonClient.SocketImplementationConfig.Add(ConnectionProtocol.WebSocketSecure, typeof(SocketWebTcp));
this.PhotonClient.Connect("wss://localhost:19091", "Hive");
}
public void DebugReturn(DebugLevel level, string message)
{
Debug.Log("DebugReturn: " + level.ToString() + " Message: " + message);
}
public void OnEvent(EventData eventData)
{
Debug.Log("OnEvent: " + eventData.Code);
}
public void OnOperationResponse(OperationResponse operationResponse)
{
Debug.Log("OnOperationResponse: " + operationResponse.DebugMessage);
}
public void OnStatusChanged(StatusCode statusCode)
{
Debug.Log("OnStatusChanged: " + statusCode.ToString());
}}
這裏是應用程序的網頁套接字聽衆在光子服務器配置中:
<WebSocketListeners>
<WebSocketListener IPAddress="0.0.0.0" Port="19091" DisableNagle="true" InactivityTimeout="10000" Secure = "true" StoreName = "MY" CertificateName = "DESKTOP-PQ845BC" UseMachineStore = "true">
</WebSocketListener>
</WebSocketListeners>
最後,這裏是我的自簽名證書:
謝謝。