Rocher0724 / socket.io-unity

MIT License
107 stars 19 forks source link

Client doesn't connect to the server ! #6

Closed Tidominer closed 2 years ago

Tidominer commented 3 years ago

Hi. I imported this package to my unity project, created an empty object and gave 'Test Object' script to it. then created a server and used the code in this package for the server(I initialized a node J s program, installed express , socket.io and nodemon ) I also created a html file which has a text inside "Server is Running" in the server directory named that "index.html". Now when I start the server, and enter this URL in a browser "http://127.0.0.1:1010" , I can see that "Server is running" message, but in unity ,when I run the game nothing happens. I can see "start" message in console but I cant see "connected" message which means it cant connect to the server. I also tried it on a new project, different ports ,localhost instead of 127.0.0.1, but didn't work. Do you know what is the problem? Thanks

leekard commented 3 years ago

Hi. I imported this package to my unity project, created an empty object and gave 'Test Object' script to it. then created a server and used the code in this package for the server(I initialized a node J s program, installed express , socket.io and nodemon ) I also created a html file which has a text inside "Server is Running" in the server directory named that "index.html". Now when I start the server, and enter this URL in a browser "http://127.0.0.1:1010" , I can see that "Server is running" message, but in unity ,when I run the game nothing happens. I can see "start" message in console but I cant see "connected" message which means it cant connect to the server. I also tried it on a new project, different ports ,localhost instead of 127.0.0.1, but didn't work. Do you know what is the problem? Thanks

Try to change server Socket.io version to 2.0.1, if you have another one

eighteight commented 3 years ago

@kirabee08 making sure that nodejs socket.io is 2.0.1 fixed the unity connection problem for me. However, now, I cannot connect from the web browser socket.io client version 3.1.0. Can you suggest which npm socket.io-client will work with socket.io 2.0.1? Thanks.

Tidominer commented 2 years ago

Thank you, It solved my problem!