Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

A little help with WebGL?

Discussion in 'Multiplayer' started by IAMBATMAN, Oct 17, 2016.

  1. IAMBATMAN

    IAMBATMAN

    Joined:
    Aug 14, 2015
    Posts:
    272
    I've checked "use web sockets", port forwarded, built a standalone, pressed "lan host"(because webgl can't be host). Then I built for WebGL and uploaded to kongregate, entered my IP, and pressed "lan client". But then I get a security error

    "An error occured running the Unity content on this page. See your browser's JavaScript console for more info. The error was: SecurityError: The operation is insecure."

    using firefox, I tried chrome but got an error there too.

    Here's a game beta access key if you want to read the console (press "lan client" to get the error)

    http://www.kongregate.com/games/Awe...f6a2d8f41a67fb32d9fd6e79a40a12c8c74c21b64866e

    What's causing this? Can you not connect WebGL clients to anything ATM? It says WebGL can't use matchmaker, and WebGL can't be host. And when I try to connect WebGL as client I get a security error.

    Anyway I hope you can help, it would be really great :)

    PS. I'm using the networkmanager hud, that's why all the buttons have "lan" in their names.
     
  2. IAMBATMAN

    IAMBATMAN

    Joined:
    Aug 14, 2015
    Posts:
    272
    It works if I launch it locally, instead of uploading it to a game portal. But that isn't much use :(
     
  3. IAMBATMAN

    IAMBATMAN

    Joined:
    Aug 14, 2015
    Posts:
    272
  4. IAMBATMAN

    IAMBATMAN

    Joined:
    Aug 14, 2015
    Posts:
    272
    I think it has something to do with http or https and security, but I don't know what to do to fix it.
     
  5. IAMBATMAN

    IAMBATMAN

    Joined:
    Aug 14, 2015
    Posts:
    272
    Can no one help me with this? I've given you all the information I have, even a link to the game so you can read the console for your self... I'd really love, if I could make my game work in browsers. I'm sure not many people would play, and I'm hosting the server my self. I don't really want this game to be a standalone :(
     
  6. Megaphone_

    Megaphone_

    Joined:
    Mar 23, 2016
    Posts:
    41
    Have you tried this without Kongregate at all to verify that it works?
     
  7. IAMBATMAN

    IAMBATMAN

    Joined:
    Aug 14, 2015
    Posts:
    272
    Yes, after I built it, I launched it from my computer and it worked fine.
     
  8. Megaphone_

    Megaphone_

    Joined:
    Mar 23, 2016
    Posts:
    41
    Sorry, what I meant was have you tried to test the networking without Kongregate across the Internet? Testing on LAN is very convenient but doesn't necessarily give you any insight if its going to work across the internet. Its kind of like starting your car in the garage for a second or two and going "Yup, it will do 100km/h no problem"
     
    Last edited: Oct 21, 2016
  9. IAMBATMAN

    IAMBATMAN

    Joined:
    Aug 14, 2015
    Posts:
    272
    Hmm... I'm not sure how I'll test that as I don't have another computer, on another network. But I'll try. I get this security error, when I try to connect to anything, even to localhost (localhost should work if I'm playing on kongregate, and hosting on the same computer, right?)
     
  10. IAMBATMAN

    IAMBATMAN

    Joined:
    Aug 14, 2015
    Posts:
    272
    I don't think I can test that, because I don't have another computer, on another network :(
    And when I try with two computers, same network, and try to connect via the server IP, it just says connecting and then fails. But if I put in my local ip, it works. I think this is something called reverse nat...
     
  11. IAMBATMAN

    IAMBATMAN

    Joined:
    Aug 14, 2015
    Posts:
    272
    I'm pretty sure this is an issue with kongregate...
     
  12. Megaphone_

    Megaphone_

    Joined:
    Mar 23, 2016
    Posts:
    41
    Localhost will not work if you're playing on Kongregate. If you cant connect to the server IP on your local machine, then something is broken with getting the connection across the internet. It sounds more like an issue with port forwarding. Again, you really really need to test this without Kongregate across the network. Try setting up a VM (Virtual Machine) if you dont have another to use.
     
  13. IAMBATMAN

    IAMBATMAN

    Joined:
    Aug 14, 2015
    Posts:
    272
    Ok, well It's definitely not an issue with portforwarding. I used the portforward network utilities from portforward.com to check if the port 7777 was open, and it was open for both UDP and TCP. I've also added rules for these ports in my firewall.

    I'll borrow another computer and try, without kongregate across the network.
     
  14. IAMBATMAN

    IAMBATMAN

    Joined:
    Aug 14, 2015
    Posts:
    272
    Ok, I opened the unity editor on my computer and pressed lan host. Then I got another computer(connected to the same internet as my computer) launched a WebGL build of my game, put in the ip from https://www.whatismyip.com/ and pressed lan client.

    It said connecting...

    and then went back to the networkmanager hud, and didn't connect.

    I got this in the firefox console.

    Firefox can't establish a connection to the server at ws://myinternetip:7777/.
    Error: undefined socket will be closed

    But when I put the ipv4 that you get when you run cmd and type ipconfig of the computer running the editor. It connects.

    Now I know there's nothing wrong with my port forwarding. So is this an issue with both computers being on the same internet, and trying to connect to the internet ip. Or is there something else wrong?