Jump to content
  • Advertisement
Sign in to follow this  
user123456789

Real-time multiplayer in a browser with node.js and HTML5 is a myth?

This topic is 2069 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all,

 

I just wanted to post a topic here which I asked recently at other forums also but didn't get yet much feedback.

 

For starters, I wan't to say that I am currently middle of process researching/writing my own first real-time multiplayer roleplaying game to browser environment using technologies such as node.js/socket.io and I have my doubts whether I finish it some day or not - so won't be showing any cool links, at least, not yet smile.png

 

The thing which really concerns me is that I have stumbled upon an issue that TCP/IP (according to many resources and literature) is just not suited for real-time multiplayer games, it works for multiplayer games with slower pace where getting responses from server with varying even bigger milliseconds (or second(s)) doens't matter and don't affect the gameplay much. For instance, Heroes of Might and magic (turn-based) in a browser? possible. Games likes the type of Diablo (real-time), not possible.

 

To be honest, this is sort of a broken dream for me.. articles (from ACM) and through internet worries me that I have jumped too early to a train of technology, which simply to put - is not there yet.

 

I have tried my best to use techniques such as prediction, delta-packets vs full world snapshots and interpolation (which is sort of under dev atm.).. which makes my game use less bandwidth and be more latency tolerant.  

 

However, the real problem is in TCP/IP itself and how it works, because socket.io communicates over it, it is argued not to be not suited for real-time multiplayer games at all.

 

The fact which concerns me most is packet loss and how TCP/IP behaves in front of it compared to UDP:

 

"..whenever a packet is lost, everything has to stop and wait for that packet to be resent. On the client game objects stop receiving updates so they appear to be standing still, and on the server input stops getting through from the client, so the players cannot move or shoot. When the resent packet finally arrives, you receive this stale, out of date information that you don’t even care about! Plus, there are packets backed up in queue waiting for the resend which arrive at same time, so you have to process all of these packets in one frame. Everything is clumped up! Unfortunately, there is nothing you can do to fix this behavior with TCP, nor would you want to, it is just the fundamental nature of it!"

 

As a reference where this text is taken, section: "Why you should never use TCP to network a multiplayer game", see: http://gafferongames.com/networking-for-game-programmers/udp-vs-tcp/

 

So to speak, TCP/IP is not suited because it will try to resend data every time again and again through the line when it detects packet loss (including all buffered data which happened to every client at that time), even more, because it tries to guarantee this delivery it is much more slower than UDP. And the problem within case of a multiplayer game is that every new user joined to a game is a big risk in terms of service quality. We all know that packet loss is way too common.

 

In favor of TCP/IP I must say that I would really like to use it - I though that I could use it, but facts are really getting into me at this point. I have also seen resources like http://onedayitwillmake.com/blog/2011/08/creating-realtime-multiplayer-games-using-node-js/ which demonstrates that "hey this can be done". But lets be real, that is an example with few clients connected to a localhost? (At least, it looks like it) rather than running a remote server under real circumstances.

 

The thing which I also noticed earlier is that in node.js you can send messages using "volatile" flag while emitting, to avoid resending when failure is detected, however as I traveled through google I began to understand that it was only some internal queue issue rather than somehow mystically getting rid of problems of TCP/IP ?

 

Now, the question is - does someone have actual facts and proofs that TCP/IP is a winner in terms of real-time multiplayer games for browser environment or not? sad.png Can it be done? and how? I am sort of a in a dead end right now.

 

If I need to abandon the idea of TCP/IP and just go for the UDP, within browser environment it is sort of "impossible" I found this reference: http://blog.alexmaccaw.com/chrome-tcp-udp but that's basically it, pretty limited.

 

Why this thing is bugging me is that I feel that I have tried to make own multiplayer rpg many times at the past and finally when I am comfortable actually making it (and have the skills to make it), I see a big wall in front of me. As a bright side, I am much better programmer at this point than ever before. tongue.png

 

If UDP is the only way, I might quit my dream of making it to browser environment, that being said I also know java/c# and some c++/c just push me towards to making this all happen.. I would just hate to start it all over again to different environment.

 

Thnx, hopefully posted to a right forum, i need answers from other multiplayer game developers smile.png

Share this post


Link to post
Share on other sites
Advertisement

Realm Of The Mad God.
Real-time; Multiplayer; Client is written in Flash and can be played in browser.

So, yes, it can be done.

 

Hmm that's a good point, I actually remember trying it once before.. even though it's with flash I assume that it really goes over TCP/IP (right!?) and works so well, that would be really good news rolleyes.gif

Share this post


Link to post
Share on other sites
World of Warcraft uses TCP. A bunch of real-time-strategy games use TCP. Whether you *need* UDP or not is dependent on your gameplay.

If your gameplay is twitch-based, first-person-shooter style, then no, TCP probably won't be a good choice.
If your gameplay can accept some command latency or sync latency, then TCP can give you much better compatibility than UDP, because you can run it in the browser (websockets, etc.)

For most games, I'd rather have 10,000 players that play something because it's fun and easily accessible, and sometimes complain about an occasional lag spike, than 10 players that can download and play an installable game for some particular platform.

Another reason to use UDP is if you need player-hosted servers, in which case the UDP NAT punch-through story is better (higher compatibility) than TCP.

Share this post


Link to post
Share on other sites

Another item to keep in mind is that UDP is no longer a guaranteed win in any case.  Many routers are configured to prioritize tcp over any form of UDP and as such have a very high drop rate for games.  Given this, the increased logic of routers to handle tcp packets better, along with the generally higher loss rate of UDP compared to even a few years ago, TCP *can* often provide better gameplay than even the best UDP.  Keep in mind, I'm not saying UDP sucks and you should not use it, just that as far as the win scenario goes, it is no longer easily cut and dry like it was.

Share this post


Link to post
Share on other sites

Thnx for the replies hpus0603, SeanMiddleditch and jbadams. Very interesting details, I definitely continue my project further and use all the techniques I can find and think of which could benefit making a game over TCP.. even if it means making small gameplay compromises, which I will make if game experience benefits from them. thnx!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!