Problem with node, socket.io and my server

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
User avatar
Talismar
Posts: 7
Joined: Tue May 29, 2012 7:03 pm

Problem with node, socket.io and my server

Post by Talismar »

Hi everybody,

Let me try to explain my problem:

Three day ago I decided to create a multiplayer game in html5. I downloaded nodejs, socket.io, watched the excellent tutorial from hallsofvallhalla on youtube and began to devellop a little square who moves with the arrows keys.

Now everythin works localy I mean I can open two different tab and play in multi with my litte black square :)
Yesterday I was very happy to manage this, because I already tried a few months ago but without results...

But today I decided to put my webserver online. I added few rules on my router and then my friend was able to acces to my index.html and play with the square. But..... We can't see each other, we only can play alone and I can't see the connection of my friend on the socket.io logs.

Here my configuration:

- A wamp webserver on port 8085
- Nodejs and socket.io are running on port 8000
- 2 rules to forward my external IP to mine (one by port)


My index.html is very basic I call few scripts to create and move my square and I call the socket.io.js like explained on all the tutorials.

Do you have any ideas to help me ??

It would be very great !

Many thanks in advance for your replies.

And sorry if my english is not very good (I am form Switzerland :)
User avatar
Talismar
Posts: 7
Joined: Tue May 29, 2012 7:03 pm

Re: Problem with node, socket.io and my server

Post by Talismar »

Well... Nobody tried to use node and socket.io in "online mode" ? :|

I am so sad... I will throw my project away again because I don't see the interest to be able to play my game in local mode only ^^
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: Problem with node, socket.io and my server

Post by Jackolantern »

Hmmm...give it a little while. We do have some Node users on here, but one of them just needs to read this topic :)
The indelible lord of tl;dr
User avatar
Talismar
Posts: 7
Joined: Tue May 29, 2012 7:03 pm

Re: Problem with node, socket.io and my server

Post by Talismar »

Otherwise what can we use to create an online multiplayer game (real time) ?

I always find topics about nodejs but there certainly are other was to do it ? no ? :geek:
User avatar
Ark
Posts: 427
Joined: Wed Jun 01, 2011 10:25 pm

Re: Problem with node, socket.io and my server

Post by Ark »

Hi, i've got a shitty game online on a linux VPS that uses node.js and socket.io. One problem which I had was that when I closed my console after running "node app.js", was the server closed and couldn't get the sockets to connect on the server (sorry if my english is bad).

so to have the node keep running permantly use Forever.

install it

Code: Select all

npm install forever
and use it

Code: Select all

forever start app.js
not sure but I think this is linux only :/
Orgullo Catracho
User avatar
Talismar
Posts: 7
Joined: Tue May 29, 2012 7:03 pm

Re: Problem with node, socket.io and my server

Post by Talismar »

I can try but even if I didn't close the console after running the js script it doesn't work.

It strange because on my computer I am able to open two browser (using the external IP of my server) and see 2 players in the game.
User avatar
Ark
Posts: 427
Joined: Wed Jun 01, 2011 10:25 pm

Re: Problem with node, socket.io and my server

Post by Ark »

Hmm what does the console says when there's a new player or client joins? Does the console says something like "info handshake authorized 1234215" ? and does it broadcast packets? And also what about the other client that you said he doesn't sees any other player, if he's on chrome check the javascript console, does it says something like "io is not defined"
Orgullo Catracho
User avatar
Chris
Posts: 1580
Joined: Wed Sep 30, 2009 7:22 pm

Re: Problem with node, socket.io and my server

Post by Chris »

Talismar wrote:I can try but even if I didn't close the console after running the js script it doesn't work.

It strange because on my computer I am able to open two browser (using the external IP of my server) and see 2 players in the game.
There's a reason why it's not working, doesn't just magically decide not to. Make sure you have port forwarded both ports, 8085 and 8000. I'm guessing that because they are both running on the same box, it shouldn't be a problem that web-sockets can only be established with the same server as the initial http request.

Also if you are both on the same network, you shouldn't need to port forward.

What browser are you both using? Use developer tools to see what's going wrong with the client side end of things (f12 in most browsers).

Do some debugging in you node server using "console.log()" and see what the server is spitting out in the command prompt.
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
Talismar
Posts: 7
Joined: Tue May 29, 2012 7:03 pm

Re: Problem with node, socket.io and my server

Post by Talismar »

@Ark Nothing happens in the console when a new player try to connnect.... I need to check the JS error on chrome, that's a good idea.

@Chris I forwarded the both port but I didn't try to use the same port for web-socket and my wamp server but I heard that i could be a problem to use the same port but I am going to try tonight.

I let you know for the js errors and the port forwarding.

Thanks for the help :)
User avatar
Talismar
Posts: 7
Joined: Tue May 29, 2012 7:03 pm

Re: Problem with node, socket.io and my server

Post by Talismar »

Everything should be good with the ports forwarding because I can acces remotly to web-socket server and wamp server.

The js error when I open my game in another computer says: cannot load ressources...

You can try if you want I let my server online for a while: http://31.31.57.135:8085/gameProject/public/

I think the problem is thise code line: <script src="http://31.31.57.135:8000/socket.io/lib/ ... "></script>

This line is in my index.html, it call the js script to run the socket.io. I tried to change the path of this link many times and I am still don't sure if it's really the way we need to call the script.
Post Reply

Return to “Advanced Help and Support”