Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to create wss connection in WebGL? (ws does not work under https)

Discussion in 'Multiplayer' started by AIVIK, Feb 4, 2016.

  1. AIVIK

    AIVIK

    Joined:
    Feb 12, 2015
    Posts:
    14
    Usual websockets works ok in WebGL through NetworkTransport. But when i try to connect from under https, it says:
    Uncaught SecurityError: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS

    How should I create secure connection?
     
  2. AIVIK

    AIVIK

    Joined:
    Feb 12, 2015
    Posts:
    14
    Looks like, WebGL finally released months ago, but NetworkTransport team just slighly forgot to make it work in https case (all social platforms?..)
    Hey, Web player is dead, don't be so irresponsible with WebGL! It is still like maze with traps!
     
  3. AIVIK

    AIVIK

    Joined:
    Feb 12, 2015
    Posts:
    14
    I enable exceptions - game is working but slower.
    I disable exceptions - game is crashing where it shouldn't and no info. Ok, i'll try to make release build with exceptions.
    Everything in single thread and lazy initialization - what a terrible combo.. Everybody writing hacks to initialize things on start of scene?..
     
    Last edited: Feb 4, 2016
  4. AIVIK

    AIVIK

    Joined:
    Feb 12, 2015
    Posts:
    14
    WebGL is still pain for somewhat complex game.. Thanks it looks like working...
    But stop. How should i know it doesn't crash here and there?.. ) It totally stops on any exception that can be..
     
  5. krab24

    krab24

    Joined:
    Mar 2, 2015
    Posts:
    20
    I have the same problem.
    What sense of WebGL in unet. A can't share my game.
    P.S. I have certificate, but I can't add this certificate on unet server.
     
  6. krab24

    krab24

    Joined:
    Mar 2, 2015
    Posts:
    20
    I used Nginx Websockets ssl proxy.

    Thank you guys.
     
  7. p627

    p627

    Joined:
    Apr 12, 2014
    Posts:
    23
    I try days to find a solusion to post my WebGL game in facebook with https without luck. Can you please tell me where do you found the tutorial? Thank you
     
  8. krab24

    krab24

    Joined:
    Mar 2, 2015
    Posts:
    20
    I do not have the tutorial.
    If you already have the certificate then this is tutorial for you:
    I used Nginx server.
    You can download this server, then you try to go in "conf" folder.
    Then you need to open "nginx.conf"
    Then use this config: https://github.com/nicokaiser/nginx-websocket-proxy/blob/master/simple-wss.conf
    ssl_certificate - your certificate file
    ssl_certificate_key - your certificate key
    listen 443 - incoming port
    proxy_pass http://localhost:8080; - your local port(without ssl)
    After - you need to start nginx server.
    This is works fine for me. But I think I have small delay because of this.

    If you don't have the certificate - you should get certificate.

    Good luck and sorry for my bad english:)
     
  9. AlekseyKhomenko

    AlekseyKhomenko

    Joined:
    Feb 17, 2016
    Posts:
    7
    Could you tell about your unet server settings? Is it listening only localhost and 8080 port, enabled useWebSockets or disabled?
     
    Real_Siege likes this.