6
votes

I has been developed multiplayer unity3d shooter with photon network(PUN). It builded fine and running for windows(exe), but it does not work in browser(web gl).

Test project without photon works fine in browser. I think the problem linked with photon. There are several exceptions in js console.

Build is hosted on

google drive. Could You please explain the reason of this problem?

Unity3d 5.3.1. Photon Unity Networking v1.65. Build was tested with chromium, firefox and internet explorer. Windows 7 x64.

2

2 Answers

6
votes

WebGL do not have regular sockets, it use instead WebSockets wich are TCP connections with an handshake that is threated by regular Web Servers as an Upgrade Request (It is not a Upgrade request!).

Now, Photon is already WebGL aware and will use WebSockets nicely, the problem however is that WebSockets are a different protocol from a regular TCP connection and hence require a dedicated server supporting WebSockets to keep a connection alive (You cannot can listen with a PHP page as long as you don't want to keep a PHP script running for very long times, I'm not even sure PHP can do that, commenters will have their work here). A very easy to setup server for WebSockets comes with NodeJS wich however requires you to learn a new language and a new architecture.

Have you already tried to connect to Photon online services? As far as I know the "Photon cloud" should answer correctly to WebSockets.

If you are connecting clients in a P2P fashion (Unity Master Server) then you need to check if MasterServer is supporting WebSockets and if you search any error you should search it over WebSockets protocol.

(It is not hard implementing your server, it may require 1 month, but implementing a clever server is just out of the chance of 1 person alone)

1
votes

Problem solved. Bug was in unity 5.3.1. Version 5.3.2 works fine