setup photon server for webGL
Options
Flatron
✭
I have a problem connecting to the photon server by unity webGL
if it's possible please help me to config my photon server(Photon Server v5)
normally I can connect to my photon server but when I want to build a WebGL and I change the platform to WebGL, the connection to the server always fails.
if it's possible please help me to config my photon server(Photon Server v5)
normally I can connect to my photon server but when I want to build a WebGL and I change the platform to WebGL, the connection to the server always fails.
0
Comments
-
I did this and now I can connect in unity but in the browser, I cannot connect.
these are the errors from the browser console:
WebSocket connection to ‘wss://photon-dev.emergents.com:19093/?libversion=4.1.6.4&sid=30&app=NameServer’ failed:
_SocketCreate @ EmergentsDemo.framework.js:2
EmergentsDemo.loader.js:1 writeStringToMemory is deprecated and should not be called! Use stringToUTF8() instead!
printErr @ EmergentsDemo.loader.js:1
EmergentsDemo.framework.js:2 Exiting receive thread. Server: wss://photon-dev.emergents.com:19093:0 Error: Abnormal disconnection.
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String)
ExitGames.Client.Photon.<ReceiveLoop>d__12:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
here is our config:<HTTPListener
Name="*:[PORT]::Master"
IPAddress="0.0.0.0"
Port="19090"
DisableNagle="true"
InactivityTimeout="10000"
Secure="true">
<Routing>
<Route
Url="/+"
OverrideApplication="Master"
PeerType="WebSocket"
Counters="false"
/>
</Routing>
</HTTPListener>
<HTTPListener
Name="*:[PORT]::Game"
IPAddress="0.0.0.0"
Port="19091"
DisableNagle="true"
InactivityTimeout="10000"
AppDataInactivityTimeout="15000"
Secure="true">
<Routing>
<Route
Url="/+"
OverrideApplication="Game"
PingEvery="2000"
PeerType="WebSocket"
Counters="false"
/>
</Routing>
</HTTPListener>
<HTTPListener
Name="*:[PORT]::NameServer"
IPAddress="0.0.0.0"
Port="19093"
DisableNagle="true"
InactivityTimeout="10000"
AppDataInactivityTimeout="15000"
PermittedOrigins="our server url"
Secure="true">
<Routing>
<Route
Url="/+"
OverrideApplication="NameServer"
PeerType="WebSocket"
Counters="false"
/>
</Routing>
</HTTPListener>0 -
I am using PUN2
version pun:2.34.1 photon lib:4.1.6.4
Photon-LoadBalancing-20210819.log at:
https://drive.google.com/file/d/1HrJPq8TOHQAe1GuxoLg_C7TI-FYRuGlx/view?usp=sharing
Thank you0 -
Any documentation on how to create a valid, signed, and trusted by browser?
We already created a server certificate based on https://doc.photonengine.com/zh-CN/server/current/operations/certificate-setup0 -
The approach is correct, but due to browser changes, it is almost impossible to find out what is going on, as browsers (checked on Firefox and Chrome) do not report exact connection error into console anymore. But it is the most likely that your browser doesn't trust the cert. To enable it, please try to open
https://photon-dev.emergents.com:19093
in your browser (replace wss with https, see section https://doc.photonengine.com/zh-CN/server/current/operations/certificate-setup#chrome_console_error__err__cert__invalid__authority), then allow it to connect even if untrusted, but then you'd have to save the cert to a file (check here https://www.ge.com/digital/documentation/historian/version91/t_hgs_enabling_trust_for_a_self_signed_certificate.html) and then install the cert as a Trusted root cert. Then the connection should work.
You can also try to use curl to debug any other errors with cert on wss. Try to use a command similar to this:curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: photon-dev.emergents.com" -H "Origin: https://photon-dev.emergents.com" "https://photon-dev.emergents.com:19093/?clientversion=4.1.5.2&sid=30&app=NameServer"
The other way is getting a cert from a trusted authority.0 -
Thanks a lot for your help.
this is curl responce:curl -i -N -H “Connection: Upgrade” -H “Upgrade: websocket” -H “Host: photon-dev.emergents.com” -H “Origin: https://photon-dev.emergents.com” “https://photon-dev.emergents.com:19093/?clientversion=4.1.5.2&sid=30&app=NameServer” HTTP/1.1 400 Handshake headers do not include an “Sec-WebSocket-Version” header Content-Type: text/html Connection: Keep-Alive Keep-Alive: timeout=10 Cache-Control: private, max-age=0, no-cache, no-store Pragma: no-cache Expires: Mon, 29 Apr 2013 21:44:55 GMT Access-Control-Allow-Origin: https://photon-dev.emergents.com Content-Length: 66 (edited)
We got the certificate from trusted authority0 -
And what about browser, when you try to open
https://photon-dev.emergents.com:19093
? You should get something like this:
0 -
-
@Flatron oh.. and you still can't connect? Well, I am a little bit out of ideas, to be honest:-) I've tried the same setup and when the certificate is considered valid by Chrome, it all works for me...
Could you please rebuild the app with PUN logging set to Full and Network logging set to ALL (both in PhotonServerSettings.asset) and post log from browser console while trying to connect to the server?0 -
Connecting...
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
PhotonClassHandler:Connect()
Assets.Scripts.Core.Game.PhotonRulesEngineHandler:Setup()
Core.Game.RulesEngineConnector:Setup(Boolean)
Core.Game.GameplayController:Setup()
Core.Game.GameplayController:Start()
emergentstest.framework.js:2 Using NameServerPortInAppSettings: 19093
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String)
Photon.Realtime.LoadBalancingClient:GetNameServerAddress()
Photon.Realtime.LoadBalancingClient:get_NameServerAddress()
Photon.Realtime.LoadBalancingClient:ConnectToNameServer()
Photon.Pun.PhotonNetwork:ConnectToBestCloudServer()
Photon.Pun.PhotonNetwork:ConnectUsingSettings(AppSettings, Boolean)
Photon.Pun.PhotonNetwork:ConnectUsingSettings()
PhotonClassHandler:Connect()
Assets.Scripts.Core.Game.PhotonRulesEngineHandler:Setup()
Core.Game.RulesEngineConnector:Setup(Boolean)
Core.Game.GameplayController:Setup()
Core.Game.GameplayController:Start()
emergentstest.framework.js:2 new SocketWebTcp() for Unity. Server: wss://photon-dev.emergents.com:19093
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String)
ExitGames.Client.Photon.SocketWebTcp:.ctor(PeerBase)
System.Reflection.MonoCMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoCMethod:InternalInvoke(Object, Object[])
System.Reflection.MonoCMethod:DoInvoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MonoCMethod:Invoke(BindingFlags, Binder, Object[], CultureInfo)
System.RuntimeType:CreateInstanceImpl(BindingFlags, Binder, Object[], CultureInfo, Object[], StackCrawlMark&)
System.Activator:CreateInstance(Type, BindingFlags, Binder, Object[], CultureInfo, Object[])
System.Activator:CreateInstance(Type, Object[])
ExitGames.Client.Photon.PhotonPeer:Connect(String, String, String, Object, Object)
Photon.Realtime.LoadBalancingClient:ConnectToNameServer()
Photon.Pun.PhotonNetwork:ConnectToBestCloudServer()
Photon.Pun.PhotonNetwork:ConnectUsingSettings(AppSettings, Boolean)
Photon.Pun.PhotonNetwork:ConnectUsingSettings()
PhotonClassHandler:Connect()
Assets.Scripts.Core.Game.PhotonRulesEngineHandler:Setup()
Core.Game.RulesEngineConnector:Setup(Boolean)
Core.Game.GameplayController:Setup()
Core.Game.GameplayController:Start()
emergentstest.framework.js:2 WebSocket connection to 'wss://photon-dev.emergents.com:19093/?libversion=4.1.6.4&sid=30&app=NameServer' failed:
_SocketCreate @ emergentstest.framework.js:2
emergentstest.loader.js:1 writeStringToMemory is deprecated and should not be called! Use stringToUTF8() instead!
printErr @ emergentstest.loader.js:1
emergentstest.framework.js:2 Exiting receive thread. Server: wss://photon-dev.emergents.com:19093:0 Error: Abnormal disconnection.
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String)
ExitGames.Client.Photon.<ReceiveLoop>d__12:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
_JS_Log_Dump @ emergentstest.framework.js:2
emergentstest.framework.js:2 SocketWebTcp.Disconnect()
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String)
ExitGames.Client.Photon.SocketWebTcp:Disconnect()
ExitGames.Client.Photon.<ReceiveLoop>d__12:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
emergentstest.framework.js:2 TPeer.Disconnect()
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String)
ExitGames.Client.Photon.TPeer:Disconnect()
ExitGames.Client.Photon.IPhotonSocket:<HandleException>b__52_0()
ExitGames.Client.Photon.MyAction:Invoke()
ExitGames.Client.Photon.TPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
Photon.Pun.PhotonHandler:Dispatch()
Photon.Pun.PhotonHandler:FixedUpdate()
emergentstest.framework.js:2 SocketWebTcp.Disconnect()
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String)
ExitGames.Client.Photon.SocketWebTcp:Disconnect()
ExitGames.Client.Photon.TPeer:StopConnection()
ExitGames.Client.Photon.TPeer:Disconnect()
ExitGames.Client.Photon.IPhotonSocket:<HandleException>b__52_0()
ExitGames.Client.Photon.MyAction:Invoke()
ExitGames.Client.Photon.TPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
Photon.Pun.PhotonHandler:Dispatch()
Photon.Pun.PhotonHandler:FixedUpdate()
emergentstest.framework.js:2 OnDisconnected
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
Assets.Scripts.Core.Game.PhotonRulesEngineHandler:OnDisconnected()
UnityEngine.Events.UnityAction:Invoke()
UnityEngine.Events.InvokableCall:Invoke()
UnityEngine.Events.UnityEvent:Invoke()
PhotonClassHandler:OnDisconnected(DisconnectCause)
Photon.Realtime.ConnectionCallbacksContainer:OnDisconnected(DisconnectCause)
Photon.Realtime.LoadBalancingClient:OnStatusChanged(StatusCode)
ExitGames.Client.Photon.<>c__DisplayClass109_0:<EnqueueStatusCallback>b__0()
ExitGames.Client.Photon.MyAction:Invoke()
ExitGames.Client.Photon.TPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
Photon.Pun.PhotonHandler:Dispatch()
Photon.Pun.PhotonHandler:FixedUpdate()0 -
Unity 2020.3.16f1
OS: macOS Big Sur V 11.2.30 -
tried on windows 10. also tried in a complete new project with photon demo samples, no luck.
we are able to connect to photon cloud but not to our self hosted photon server.
our photon server sdk version: photon-server-sdk_v5-0-12-24499-rc10 -
hi, @TaherSamadi
could you try this on another machine?
for instance on some VM or friends pc
best,
ilya0 -
Hi, we did test on 2 different PCs. Still not able to connect
0 -
Update: we were able to connect using 443 port.2
-
@TaherSamadi did you use this port on both, server and client? Well, I'd suggest to check for some firewall issues, it does not seem like a photon server configuration issue.. Btw, did you also tried running the server on a different machine, or just clients?0