Noobhub - Free Opensource Multiplayer And Network Messaging For Coronasdk

I think I understood where the problem is in Noobhub. During the initial connection, I didn’t set up zero timeout… Ooops, here are UI hangs if theres no internet at all :slight_smile: I just never tested this case… :slight_smile:

Didn’t get why you opened port on your router… Server with nodejs is supposed to have public accessible IP with no magic with routing. And client (corona sdk) is able to connect to it through any router from any subnet (with exception of networks with explicit security).

My test server IP is hardcoded in demo code, you can use it meanwhile you set up your own server.

@Overtorment

It works with your server nut I have to find the way so will work on my own server. I have Ubuntu Server. I dont know if this helps. Maybe a port opening, something in iptables… Something… Just give me your lights

Thanks again

Hello all. You might remember me @overtorment, when you released noobhub I was one of the first few guys to start using it. I’ve got comments all over the original noobhub thread. Anyways, noobhub has worked great in my children’s game “Math Race Online” since late August w/ the exception of the small bug where node would catch an error and end the script. Since you fixed that and released the new nodejs a few months back, the script has literally been running for 2 months straight without a single restart, which is fantastic! I’m using noobhub in a new project, and I am running into a small barrier. The app has to keep time in sync between the user and the host. so if a user joins a room, and the game is at 25 minutes 30 seconds and 873 milliseconds, the host has to send that time to the user and the user needs to know (almost) exactly how long ago the host send that number, so that say if the host sends to the user:

Time: 18 minutes, 3 seconds, 322 milliseconds,

then when the user receives that pong, I need the user to know how many milliseconds ago the request was sent so that the number of milliseconds of latency can be removed from the actual time sent by the host so that the host and the user are in sync.

My question is, is there anything built into noobhub that tells you what the latency of a ping/pong was? I thought about just having the host send a (1) ping, storing the system.getTimer() when the ping was sent, then (2) when the client receives this ping, pong the host back acknowledging ping received. then the host can substract the new system.getTimer() from the old one when the ping was sent, and divide that by 2 and send that to the client notifying them that is the latency in milliseconds. Obviously this wouldn’t be fully accurate, but I was in a rush when I thought of it. If there isn’t anything built in to tell latency, does anyone have any suggestions of ways this could be custom coded?

Note: the time has to be in milliseconds, not seconds.

Thanks!

Tyler

Can we make noobhub save some data? For example to create a leaderboard. :rolleyes:

Hello Tyler!

Glad youre making use of Noobhub.

Regarding the lag determination - you’re on the right track, but here, take a look at algorithm I came up with to determine lags for my own game.

lag_compensation.png

Basically,  A constantly pings B, and saves ping latency to determine basic network latency.

And tracking timestamps of message  sending/receiving, it is possible to tell  how much more message was delayed on top of the basic network latency. Take a look at the scheme I made.

I was thinking about it, and created a solution which doesn’t involve server code modification.

Basically, I made a php script hang on some noobhub channel, so it can do some backend work, like saving and retrieving data.

Example script is in “client/php/” folder.

Cheers!

That works for me! The app just needs to sync times once between the host and the users, so I won’t have to worry about rechecking constantly because once I know the ping I can subtract it from the round time and start the timer, so good to go there. Thanks a lot!

Tyler

When noobhub starts what is the console output?

My output is Noobhub on 0.0.0.0:1337
Is that right?

@yiannis yes, when you run the script that is the first thing that shows up in the log. that means you have successfully started the script

Excuse my ignorance, but can you explain how are you using php client for commands like img1.x=111.

I would also like to know (if satheesh from discussion on http://developer.coronalabs.com/code/noobhub is here) 

how his application is working without Internet connection. As I understand that would mean that node is running on mobile phone !?

Hey @overtorment or anyone else who knows the answer to this, all of a sudden im randomly getting this error “Exception: Error: ETIMEDOUT, Connection timed out” after using the same channel consistently. Any idea what is causing this error? It’s not letting the channel continue to be used, and is displaying the error “Exception: Error: Socket is not writable” whenever I try to ping/pong it after it gives me the initial error. If there’s any way to fix this I’d love to know, just worried that the cause is from excessive use of a channel. But if that’s the case then it’s going to be a problem for my app.

Thanks,

Tyler

Tyler, have you updated client’s lib (noobhub.lua file) ?

In latest version I implemented auto-reconnect if connection gets broken (timeout or anything else), I believe this should fix your issue.

@drazen007bond

In my game I implemented simple command recognition engine, so game can receive some command to change coordinates of something, and do it. For that, game subscribes to a dedicated channel, like, “debug-channel”.

I set-up my php script to connect to the same channel “debug-channel”, and type commands. 

Overtorment,

I tried it on your server and i love it.

but i am new to node and i was trying to install it on AppFog.

now i am stuck and i have no idea what i am doing.

pls someone help me!

    var app = require(‘express’).createServer();
    app.get(’/’, function(req, res) {
    res.send(‘Hello from AppFog’);
    });
    app.listen(process.env.VCAP_APP_PORT || 3000);

how do i use that port in lua.

thanks in advance

AFAIK  AppFog doesnt provide external IP, so client wont be able to connect to nodejs server. 

So get a VDS first, with a public IP.

Then, install nodejs and run server.

i c.  thank you

@overtorment Yes the noobhub.lua and node.js files im using are both the newest versions. I’m getting this error that socket is not writable in 2 different VPS’s that im using. Any idea what could be causing this? Note: This error only shows up after using the socket for a bit, it usually doesn’t happen right away after using a new channel id. For example, normally my app gives a user a new room ID when hosting a new room, and room id’s are between 10000000 and 99999999. However, for testing purposes I’m manually setting the room code so that all my devices are on the same channel while developing. Once I get this error, that room id, for example another room id(channel) that as of 2 minutes ago doesnt work now is 66748858 This isn’t usable at all. If I went back tomorrow and tried to use it, it would continue to say socket not writeable. This is reset when I stop the node.js and restart it using forever in ubuntu, which I am using to keep the script continually running.

I got that… should use that idea …thnxs!

  1. Check noobhub.lua if it has method   self:reconnect()  If not - this is not latest version

  2. Tell me nodejs version, maybe this is something specific to version

  3. Open server code  (node.js) and make sure that “verbose” is set to true, then, run server without forever.js and redirect output to log file (or check forever.js log files if present). Reproduce the issue and post error messages if any. BTW, I had funny issues when in verbose mode my nodejs server filled whole disk with logs… Maybe that is your case?

@overtorment

  1. Yea noobhub.lua includes the self:reconnect() function. I made sure and also replaced the local version I had with the version on github and it’s still having errors.

  2. Node running on ubuntu, “npm -v node” returns “1.0.106”

  3. Verbose is set to true, and I ended node.js through forever and ran it by node node.js and still got the error a little bit after using it.

I still have all of the forever logs. The error messages that I get are the following:

  • Exception: Error: ETIMEDOUT, Connection timed out

The first time this shows up is right after a client subscription to a channel. The channel is 66748857, I doubt it has anything to do with the channel name being an integer but just wanted to note that. 

After that error message appears, anytime a client attempts to publish to the channel, this error appears:

- Exception: Error: Socket is not writable

That’s not  nodejs version, it’s  npm version

use

$ nodejs -v