running $ nodejs -v or nodejs -v gives “-bash: nodejs: command not found” not sure if that’s because I installed nodejs through forever. And the node.js i am using it the 3 month old version on the github repository updated w/ what you said to do of adding the socket timeout that was a replicate of socket close. Emailing the log now
Okay so find the installed nodejs binary and run it with -v key
Should be: node -v (not nodejs)
they fixed it in latest versions, since sometimes people get confused a s “node” refers to other absolutely not related package.
Which OS do you get nodejs (as the binary name) working? It doesn’t work in CentOS…
burn@gaia:~$ uname -a
Linux gaia 3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:31:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
burn@gaia:~$ nodejs -v
v0.10.9
Did you build from source? I’m running v0.10.10 on three different servers (CentOS 6.4 on OpenVZ and KVM), all were built from source and only “node -v” works.
I am not sure if this is the right place for my issue.
I am not new to corona. But I am new to noobhub as well as socket handing.
We have been developing a card game and we have a script in the server to open the ports. When we pass a request from the device it checks if the port is open. The port opening script is called using a Cron Job every half an hour since the port closes automatically.
This script returns an error every time the port is already open. Due to this function being called every half an hour the server gets stuck due to the pilling up of these errors
<?php
$address = “108.xxx.xx.xxx”; //server address//
$port = 9875; //port to which client connects//
$max_clients = 100; //max clients at a time//
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); //creating a socket//
socket_bind($socket, ‘0.0.0.0’, $port); //binding the socket with port//
$sock_data = socket_set_option($socket, SOL_SOCKET, SO_BROADCAST, 1);
$from = ‘’;
$port = 0;
//recive the incomng data through the port until data is not received//
do {
$pkt=socket_recvfrom($socket, $input, 65535, 0, $from, $port); //$sockect = socket, $input = the data that is sent from the device, $from = Sender’s IP, $port = Sender’s port//
if ($input == null)
{
}
else
{
echo $input;
socket_sendto($socket, $input, strlen($input), 0, $from, $port); //reply to the client(device)//
}
}
while ($pkt !== false);
?>
This is the error that is returned:
Warning: socket_bind() [function.socke
t-bind]: unable to bind address [98]: Address already in use in /home/xxx/public_html/portlisten/servertest.php on line 10
could not bind socket
Can anyone suggest a way to keep the port open so that this script does not need to be used. Or can anyone suggest a way to avoid the error that comes up if the connection is already set.
youre doing something with UDP, not TCP/IP.
check out sample php script which comes with noobhub. it works fine.
also, there are card games on appstore which successfully run on noobhub.
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
Hi, Overtorment
I am having troubles to keep a channel limited to 2 players. This would only happen if 2 players at the same time click to join another (third) player. What I do is I set in MongoDB a flag that a player is not anymore in his lobby channel. After a player clicks on connect I noobhub publish via Corona a check to see if the other player is still available. A callback gets sent back to Corona whether the other player is available.
Is it possible to close a socket connection on the server? Cause I can check how many players are in the same channel with the following code. But I am not sure how to close the connection on that player.
// list all connections in the same Match channel, check if not more than 2 players are connected by accident if (socket.channel.substr(0, 6) == 'Match\_') { console.log('\*\*\* Match channel number of player check. Connections in the same channel:'); var numberOfConnections = 0 for (var prop in sockets[socket.channel]) { numberOfConnections++; console.log(numberOfConnections + '. channel: ' + socket.channel + ', conn\_id (key) is: ' + prop + '. Value is: ' + sockets[socket.channel][prop]); if (sockets[socket.channel].hasOwnProperty(prop) && numberOfConnections \> 2) { // delete sockets[socket.channel][prop] - doesnt work console.log('\*\*\* To many players for a Match\_, need to remove prop: ' + prop + ' from channel: ' + socket.channel) } } }
…or what would be another way to make sure only 2 people can max connect to eachother out of a list of friends.
thx a lot
How do I pair basic http/s authentication and paths with socket.connect? I would think this is the common case for websockets, but I could be wrong. I’ve tried to play with Noobhub to get it to work but I’ve not made much progress.
I have a url that includes the basic auth:
myuser:mypass@someuri.com/path
and I really don’t understand how to make a good connection from that. Noobhub is happy to make a socket to someuri.com but after that it’s not clear how I’m supposed to negotiate the rest of it.
Anyone have any ideas?
Ok, I fixed my problem by simply sending a message to Corona from noobhub server. Not the most elegant way, but it works and it allmost never happens.
if (socket.channel.substr(0, 6) == 'Match\_') { console.log('\*\*\* Match channel number of player check. Connections in the same channel:'); var numberOfConnections = 0 for (var prop in sockets[socket.channel]) { numberOfConnections++; console.log(numberOfConnections + '. channel: ' + socket.channel + ', conn\_id (key) is: ' + prop + '. Value is: ' + sockets[socket.channel][prop]); } // if to many players, notify each client to cancel the match if (numberOfConnections \> 2) { var message = { "action":"ToManyPlayers\_in\_the\_channel" }; message = JSON.stringify(message); for (var prop in sockets[socket.channel]) { if (sockets[socket.channel].hasOwnProperty(prop)) { sockets[socket.channel][prop].write("\_\_JSON\_\_START\_\_" + message + "\_\_JSON\_\_END\_\_"); } } } } }
Hey @overtorment, the node.js script is still pretty extensively having the “Exception: Error: Socket is not writable” issue. My app released this weekend, and in my logs for node.js running through forever, there are a LOT of instances of this error. Do you have an email where I can send you my log if that would help? I’m hoping this is something simple that can be fixed soon so that people don’t start giving low ratings about the online part of the app.
Send log to overtorment at gmail com Ill take a look asap. Include node js version $ nodejs -v Is noobhub server library latest?
running $ nodejs -v or nodejs -v gives “-bash: nodejs: command not found” not sure if that’s because I installed nodejs through forever. And the node.js i am using it the 3 month old version on the github repository updated w/ what you said to do of adding the socket timeout that was a replicate of socket close. Emailing the log now
Okay so find the installed nodejs binary and run it with -v key
Should be: node -v (not nodejs)