• Content Count

  • Joined

  • Last visited

  1. invisal

    SAO RPG (MMORPG simulation)

    Look good even without any attack animation. Sword Art Online is no longer a dream.
  2. invisal

    WebSocket delaying the message

    Unbelievable, I tried a lot of thing and nothing works. Then, I closed Steam and the lag is gone. I have no idea that Steam could affect my computer such an extent.
  3. invisal

    WebSocket delaying the message

    I am running Windows 10 Home edition. Here goes my story: After did some researches, I thought it was the Nagle's algorithm fault. So I went to registry editor and set TcpNoDelay to 1. It does not solve my problem. I thought it might be Chrome browser. So, I downloaded Firefox and the problem is still the same. I thought maybe my firewall might cause the delay. I disabled my firewall. It does not solve my problem as well. Then, when I saw your post, I thought, maybe it is because of my computer. So I launch a $5 Ubuntu DigitalOcean Droplet and launch nodejs server there. It turns out there is no delay. Now, the real question is what cause the delay on my particular machine. I have Window Defender (default anti-virus by Windows 10) and Windows 10 Home edition. One thought that come to my mind is that Home edition is not meant for running a testing server. So, Microsoft did put some delay when trying to run a server from Home edition. Second thought, maybe it is because of my anti-virus. I will update if I find the real cause. On final note, thanks for replying my post. It is little sad that it took 2 days for moderator to approve my first post.
  4. I run into an annoying problem which I don't know how to solve. I don't know whether WebSocket Server delay sending the message or WebSocket delay receiving the message. var WebSocketServer = require('ws').Server; var wss= new WebSocketServer({ port: 88 }); var players = {}; var playerInc = 1; var gameLoopHandler = setInterval(function() { broadcast(new Date().getTime().toString()); }, 200); wss.on('connection', function connection(ws) { console.log("Player ID ", playerInc, "is connected"); // Add player to the player list var id = playerInc; players[id] = ws; playerInc++; // Listen when websocket disconnect ws.on("close", function() { delete players[id]; }) }); function broadcast(message) { for(var key in players) { try { var p = players[key]; p.send(message); } catch(ex) { } } } For every 200ms, I broadcast the timestamp of the server. Then, I compare the timestamp that I receive from my client side. var ws = new WebSocket("ws://"); ws.onmessage = function(e) { var now = new Date().getTime(); var diff = now -; console.log(, now, diff); } I expected the different to be very low since it is operating in the same machine. But here is what I get Every 500ms or 1 second, there will be a big delay. Sometimes, it takes 1 second to receive the message.