Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by scottbromander · Nov 22, 2016 at 09:06 AM · socketnodejs

Node.js + Socket.io + Heroku

I have an Node.js Server with Socket.io driving socket based interactions with the Unity Client. Additionally, I have a Web Application that connects to the same server. The Web App sends RESTful calls to the Server, which in turn broadcasts to the Unity Client.

When I run everything locally, everything works great. Web App can talk to the game, Game Client updates correctly.

Moving the server side code over to Heroku however is a different story. Nothing has changed other than the connection URL in SocketIOComponent.

Example connection URL for Heroku: ws://blooming-chamber-76501.herokuapp.com:47960/socket.io/?EIO=4&transport=websocket

I am guessing it is CrossDomain something something, but I am at a total loss after 10 hours of Googling and Foruming. Note: I did read a note about how Sockets do not work with Heroku, but got a basic Socket.io example running just fine: https://quiet-fortress-68565.herokuapp.com/

Help, advice, guidance, anything would be appreciated.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image gameslucas · Jan 21, 2017 at 06:51 AM 0
Share

Friend I am with this problem. Do you can post your code server?

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by scottbromander · Nov 23, 2016 at 07:33 AM

Figured it out! After three days of research, it turns out the connection URL needs to specifically target port 80.

Example: ws://blooming-chamber-76501.herokuapp.com:80/socket.io/?EIO=4&transport=websocket

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jacob2000 · Aug 23, 2017 at 07:08 PM 0
Share

@scottbromander I don't know how did you come up with this solution but thank god you did!

I was beginning to go berserk!!!

After I've read your solution I've came across documentation which specifies that Heroku port forward their 80 to the designated port which is being chosen when the app is deployed.

Thumbs UP! Jacob.

avatar image erofes · Oct 14, 2018 at 10:02 PM 0
Share

Thank a lot for this!

avatar image
0

Answer by chin13577 · Mar 12, 2018 at 11:55 AM

Hey ! I found the way!!.

if you run server in the localhost. the url should have ":port" example

 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-76501.herokuapp.com/socket.io/?EIO=4&transport=websocket

it's work!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Webplayer connecting to TCP server: No connection could be made because the target machine actively refused it 2 Answers

How to stream audio from unity app to the web browser? 0 Answers

How do I connect to a server in LAN from a different computer? I'm using socket.io and nodejs 1 Answer

How to set namespace in packet of socketIO using unity3d 1 Answer

Socket Io Client sent messages are not received at the Node Js server. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges