The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

WebGL + Unity 5 + (Secure)Websocket - Self Hosted - Not working

2015-09-05 03:38:52

Hello All,

I have been using PUN for awhile now but this is my first post in these forums, so hello!

Let me explain my situation. I was using Unity Web Player for builds until a couple days ago when Chrome updated their browser to finally do away with NPAPI. Many users use Chrome so the potential for players on a game goes down, when you tell people, "Sorry it doesn't work in chrome."

So I thought, okay lets do some research and see what alternatives we have for this. I came across some information from the Unity Team about a feature they're implementing called WebGL. (It works but I think it's in preview mode still.)

So this is the route I decided to go. I currently host a photonserver (so I can have the 100ccu limit) on a laptop, all ports forwarded, etc, has worked great and still does as long as I don't try to use it for Websocket hosting. I have followed the tutorial from here:

I have verified in the logs that it sees the certificate.

Since I am using my laptop as a server here is what I have done:

  1. Created the certificate in IIS
  2. Verified it in the Personal MMC Certificate folder
  3. Updated the text file with SSL info.
  4. Updated PUN from the Unity Asset store
  5. Restarted Unity
  6. Restarted my server laptop

In Unity, for the PhotonServerSettings file I have typed the following:
Server Address: (ws://laptopipaddress @ Port 9090) and I've tried (wss://laptopipaddress @ port 9091)
Tried both options above with TCP and UDP ^

Checked this documentation to make sure I'm configuring the correct ports:

I get this error with ws:// @ 9090:

Unity Error:
Exiting receive thread due to error: An exception has occurred while receiving a message. / WebSocketSharp.WebSocketException: The header part of a frame cannot be read from the data source.
at WebSocketSharp.WebSocketFrame+<>c__DisplayClass7.b__6 (System.Byte[] header) [0x00000] in :0
at WebSocketSharp.Ext+<>c__DisplayClass6.b__5 (IAsyncResult ar) [0x00000] in :0
PhotonHandler:DebugReturn(DebugLevel, String) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:173)
NetworkingPeer:DebugReturn(DebugLevel, String) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1105)
ExitGames.Client.Photon.c__Iterator2:MoveNext() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/SocketWebTcp.cs:174)

Server Log Error: MSMaster.log:
2015-09-04 23:24:33,535 [14] WARN Photon.SocketServer.Protocol [(null)] - Subprotocol GpBinaryV16 is unknown
2015-09-04 23:24:33,535 [14] WARN Photon.SocketServer.ApplicationBase [(null)] - OnInit - Failed to parse init request for WebSocket peer: {0}System.Byte[]

I get a different error with wss:// @ 9091 it actually tries to connect in Unity and won't error out but in the MSMaster.log file it says the same as above:
2015-09-04 23:26:08,705 [15] WARN Photon.SocketServer.Protocol [(null)] - Subprotocol GpBinaryV16 is unknown
2015-09-04 23:26:08,705 [15] WARN Photon.SocketServer.ApplicationBase [(null)] - OnInit - Failed to parse init request for WebSocket peer: {0}System.Byte[]

I've tried every combination of ws:// and wss:// with my public ip, local ip, udp, tcp, everything.
For now, I am able to get the game running if I go from Self-Hosted to PhotonCloud. Cloud works just fine so I'm certain there is something I'm doing wrong.

Thanks for taking the time to read this and let me know if I can provide any more information.


Edit: 9/4/2015 @ 11:43pm

I've also poked around here:


2015-09-12 06:51:08

Up, I've got the same

2015-09-17 10:53:40

Current Photon Server v3 does not support websockets. Only upcoming v4 does.

2015-10-04 14:08:20

Good deal. I'll keep checking on: until I see v4. Any eta on v4?


2015-10-06 16:20:54

I have same question as @Vectorizing . When can we expect Photon Server v4?


2016-02-01 19:35:59

Just popping back in to see if any new information on Photon Server V4 is available?


2016-02-02 20:01:40

It is close.

2016-02-03 09:25:59

Does "close" mean days? weeks? months?
What order of magnitude do you have as target for v4?
Your answer can impact the technical solution we choose for our next big project...

2016-02-03 16:10:49

Close meaning days.

Back to top