Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Can I connect Unity App with Node.js server?

Discussion in 'Connected Games' started by 8Observer8, May 11, 2016.

  1. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    98
    Hello,

    Can I connect Unity App with Node.js server by heroku.com and openshift.com?

    I try to use Unity Socket.IO Asset: https://www.assetstore.unity3d.com/en/#!/content/21721

    When I install this asset I can to use "Socket IO Component (Script)"

    I see this field on "Socket IO Component (Script)"

    Url: ws://127.0.0.1:3000/socket.io/?EIO=4&transport=websocket

    I deployed my 'server' on heroku.com I have this address: https://unitychat.herokuapp.com/

    I converted this address to IP here: http://www.hcidata.info/host2ip.cgi

    I replaced the Url field in ""Socket IO Component (Script)"" to:

    ws://176.34.115.171:3000/socket.io/?EIO=4&transport=websocket

    But I cannot connect with heroku. Why?
     
  2. 2rusbekov

    2rusbekov

    Joined:
    Jul 12, 2013
    Posts:
    36
    Have you found solution? I got same problem.
     
  3. Optimus_Prime

    Optimus_Prime

    Joined:
    Apr 15, 2015
    Posts:
    34
  4. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    98
    Yes, but only for WebGL. I used only JS version of socke.io (not Unity Socket.io) and I called JS functions by ExternalCall from C# scripts. It is the same: http://socket.io/get-started/chat/

    Yes, I do. But I cannot connect two apps. Maybe do you know a tutorial about how to connect Unity Socket.io with heroku or openshift?
     
  5. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    98
    I think that SignalR is better for WebGL and WCF is better than Node.js for desktop because you can study only C#. But I don't know could I use WCF in Unity? UNet is better for coop games, but not for massive games.
     
    Last edited: Jul 27, 2016
  6. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    98
  7. chin13577

    chin13577

    Joined:
    May 8, 2017
    Posts:
    3
    Did you find the solution?
    now I stuck in it.
     
  8. chin13577

    chin13577

    Joined:
    May 8, 2017
    Posts:
    3
    Hey ! I found the way!!.

    if you run server in the localhost. the url should have " : port"
    example (port = 47960)

    ws://127.0.0.1:47960/socket.io/?EIO=4&transport=websocket

    **but if you have deployed to heroku
    the url must delete " : port"

    ws://your-project-name.herokuapp.com/socket.io/?EIO=4&transport=websocket

    it's work!
     
    8Observer8 likes this.
  9. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    98
    Thank you very much! It is realy works!

    heroku logs --tail
    I can complete this tutorial :cool:
    Pluralsight - Unity Multiplayer Game Development with Node
    https://www.pluralsight.com/courses/unity-multiplayer-game-dev-node-2454
     
  10. 8Observer8

    8Observer8

    Joined:
    Apr 29, 2015
    Posts:
    98