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 calemb · Sep 27, 2017 at 04:47 AM · networkingwebglsocket

WebGL sockets fails: Attempt to send to not connected connection

I build (unity 2017.1 stable) some client - server connection based on tutorial: https://www.youtube.com/watch?v=qGkkaNkq8co&t=3686s&ab_channel=N3KEN

So I have own code for server and client. Last problem that I have is fail to connect using WebGL. I put server in headless mode on linux (ubuntu) VPS and editor / standalone client builds works good.

But webgl builds not....(put build at hosting & vps and both fail on Chrome, Firefox and Opera)

As manual says (https://docs.unity3d.com/Manual/UNetUsingTransport.html) I should also add:

 NetworkTransport.AddWebsocketHost(topology, 8887, null);

to server and that is done... Both Client and server receive Connect event, but when try send sth from server I got in logs: Attempt to send to not connected connection

Any idea what I'm missing?

Thanks

EDIT - ANSWER

I found answer... it's complex: 1. On client now using (as documentation says: server using different port for web socket & normal socket - and I want my server working with both in same time):

 #if UNITY_WEBGL
     private int m_port = 3002;
 #else
     private int m_port = 3001;
 #endif

  1. On server (and here was the biggest mistake). Also I must change port on another from normal socket, but:

    m_hostId = NetworkTransport.AddHost(topo, m_port, null); m_webSocketId = NetworkTransport.AddWebsocketHost(topo, 3002, null);

And I use for each response m_hostId!!!!!!!!! So now, wen request come in, I take connectionId and hostId on which it comes and answer on that connection and host ID.

For now, I think that everything works fine. There is so many small thing that matters, so be carefull.......

Thanks anyway!

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 ShantuApps · Jun 07, 2018 at 11:05 AM 0
Share

I liked your explanation... for client and for server.. in my case i have only changed server but was getting exception Firefox cannot establish connection. Which is 100% correct. $$anonymous$$y WebGL client was calling wrong port :( (7777) . but with Simple Web-socket Client - Chrome Web Store , i just tried ws port 6001, then connection opens. So, i think, it will work now.

0 Replies

· Add your reply
  • Sort: 

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

102 People are following this question.

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

Related Questions

WebSocket and WebGL error 1 Answer

Chat system is not working 1 Answer

Socket networking performance tips sought 0 Answers

LLAPI vs. pure C#.NET sockets 3 Answers

Best way to Instantiate and synchronize 300 000+ GameObjects over LAN? 2 Answers


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