PUN+ WebGL errors connecting to localhost

Options
I'm running into the following errors connecting to a Photon Plugin Server on localhost when connecting with a WebGL PUN client. Specifically I see the following errors in the Chrome browser log:
WebSocket connection to 'wss://127.0.0.1:9090/' failed: Error in connection establishment: net::ERR_INSECURE_RESPONSE
and
Exiting receive thread. Server: wss://127.0.0.1:9090:0 Error: Abnormal disconnection.

However, I am able to use the PUN client in the Unity Editor to connect without any errors, other platforms connect fine using UDP. It seems to specifically be the built client that has issues connecting.

Setup:
  • Unity 5.6.0f3
  • WebGL with code stripping turned off (tried on and off)
  • Photon-OnPremise-Server-Plugin-SDK_v4-0-29-11263 with a custom plugin
I've seen this post, but I'm barely sending any data at all and it still doesn't connect at all when running from the actual WebGL build output by Unity.

I also followed the instructions here to allow running from chrome with local file access. Microsoft Edge cannot connect either.

In order to even get the unity editor to connect I had to solve the certificate and secure websocket configuration as shown here.

So... the question is, why does the webgl client in the editor behave differently than the webgl client that actually gets built?

Anyone run into this? I must be missing something simple somewhere.
Thanks for any help!
C

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @bererton,

    Thank you for choosing Photon!

    Did you check the discussion here.
    Also this stackoverflow question could be helpful.
  • bererton
    Options
    Hi @JohnTube

    That second one especially seems likely to be helpful... thanks for the pointer. I'll dig into it. Odd that it works OK in Unity's editor, but then that's probably related to the fact that Unity just lets you connect to anything without much security, and Browsers are purposefully set up to be more secure.
  • bererton
    Options
    Indeed it seems like starting chrome with --ignore-certificate-errors allows the connection to proceed and work correctly, so it's likely a certificate error of some kind that I need to fix. Unfortunately it's not being very descriptive about the problem. It's probably just that it's a real certificate that's not meant to be used for localhost, but I don't have a ton of experience with ssl certificates running on localhost and how that's supposed to be setup.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    I think Chrome in latest versions no longer trusts self signed localhost certificates.
    You can ignore the security warning temporarily or find how you can make it disappear.
  • chaarmi
    Options

    For anyone experiencing this issue => Exiting receive thread (inside loop). Server: XXXXX

    Here is the solutions that have worked for our team:

    1. Check to see if the scene that you are loading is not MASSIVE in size.
    2. Check to see if the scene being loaded is not sending/receiving data in the first frame (Wait a while before sending/receiving sync information with Photon).

    TO TEST AND SEE IF THIS IS THE CASE:

    1. Create a FULLY EMPTY dummy scene in unity and add it to the build settings
    2. Connect to Photon and try and use that EMPTY scene to see if works (Which it most likely should). This will alert you that your issue lies in the scene you were trying to load (Due to one of the above items OR something else in that specific scene).

    Hope the above solution helps out others going through the same issues!

    Nav Gupta => Former Unity 3D Live Help Expert Team Member and now Founder and CEO of Chaarmi Worlds Inc. making the future metaverse!! Check us out at Chaarmi.com!