Category Archives: Stack Overflow
Comment by Nasser Torabzade on How to open a port below 1024 in Cent OS for socket.io?
How to open a port below 1024 in Cent OS for socket.io?
Salam (means Hello) :)
I'm trying to open port 843
in my Cent OS 5.2, I added following line to etc\sysconfig\iptables
:
-A INPUT -p tcp --dport 843 -j ACCEPT
and then updated my iptables
service. I need to listen to that port in my node.js application which is running by root user via sudo node index.js
command, but I still get forbidden port
error when I try establish a connection through that port.
this is what I get by running sudo iptables -L -v
:
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
2811 238K ACCEPT tcp -- any any anywhere anywhere tcp dpt:http
112 6224 ACCEPT tcp -- any any anywhere anywhere tcp dpt:hbci
0 0 ACCEPT tcp -- any any anywhere anywhere tcp dpt:843
41 2124 ACCEPT tcp -- any any anywhere anywhere state NEW tcp multiport dports 5901:5903,6001:6003
13093 13M ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED
26 3584 ACCEPT icmp -- any any anywhere anywhere
0 0 ACCEPT all -- lo any anywhere anywhere
109 6404 ACCEPT tcp -- any any anywhere anywhere state NEW tcp dpt:ssh
888K 80M REJECT all -- any any anywhere anywhere
and this is outpou of sudo netstat -ptl | grep node
:
tcp 0 0 *:843 *:* LISTEN 12927/node
tcp 0 0 *:http *:* LISTEN 12927/node
tcp 0 0 *:10843 *:* LISTEN 12927/node
and I try to listen to that port in socket.io with this code:
var io = require('socket.io').listen(
843,
{ log: false,
flashPolicyServer: true,
transports: ['websocket', 'flashsocket', 'htmlfile', 'xhr-multipart', 'xhr-polling', 'jsonp-polling']
}
);
io.sockets.on('connection', function(socket){
// my event listeners
});
Comment by Nasser Torabzade on Proper settings for socket.io flash (and other) fallbacks for clients using a proxy
transport
array is flashsocket
. any other suggestion? Proper settings for socket.io flash (and other) fallbacks for clients using a proxy
Salam (means hello) :)
I have the following basic settings in my node.js application. But it doesn't work for clients who are connected using a proxy or are behind a firewall. I want to know what should I add to get socket.io fallback to work as expected:
Server side:
var io = require('socket.io').listen(3000, {
log: 3,
flashPolicyServer: true,
transports: ['htmlfile', 'xhr-polling', 'jsonp-polling', 'flashsocket']
});
io.sockets.on('connection', function(){
// my event handlers
});
Client side:
WEB_SOCKET_SWF_LOCATION = "oath/to/my/copy/of/WebSocketMain.swf";
var socket = io.connect('http://localhost:3000');
// my event handlers
Proper settings for socket.io flash (and other) fallbacks for clients using a proxy
Salam (means hello) :)
I have the following basic settings in my node.js application. But it doesn't work for clients who are connected using a proxy or are behind a firewall. I want to know what should I add to get socket.io fallback to work as expected:
Server side:
var io = require('socket.io').listen(3000, {
log: 3,
flashPolicyServer: true,
transports: ['htmlfile', 'xhr-polling', 'jsonp-polling', 'flashsocket']
});
io.sockets.on('connection', function(){
// my event handlers
});
Client side:
WEB_SOCKET_SWF_LOCATION = "oath/to/my/copy/of/WebSocketMain.swf";
var socket = io.connect('http://localhost:3000');
// my event handlers
Answer by Nasser Torabzade for Ajax with deeplink
Answer by Nasser Torabzade for Centering an image larger than browser window, which can then be used as a rollover image
You can set your image as a centered background of a div:
<!DOCTYPE html>
<head>
<style>
body{
overflow-x: hidden;
}
#bigImage{
background:url('sitewide.png') no-repeat top center;
width: 2880px;
height: 540px;
}
</style>
</head>
<body>
<div id="bigImage"></div>
</body>
</html>
Answer by Nasser Torabzade for Centering an image larger than browser window, which can then be used as a rollover image
You can set your image as a centered background of a div:
<!DOCTYPE html>
<head>
<style>
body{
overflow-x: hidden;
}
#bigImage{
background:url('sitewide.png') no-repeat top center;
width: 2880px;
height: 540px;
}
</style>
</head>
<body>
<div id="bigImage"></div>
</body>
</html>
Comment by Nasser Torabzade on Centering an image larger than browser window, which can then be used as a rollover image
Comment by Nasser Torabzade on Centering an image larger than browser window, which can then be used as a rollover image
text-align:center;
to your css, it should work. I updated my answer. Answer by Nasser Torabzade for Centering an image larger than browser window, which can then be used as a rollover image
You can set your image as a centered background of a div:
<!DOCTYPE html>
<head>
<style>
body{
overflow-x: hidden;
}
#bigImage{
background:url('sitewide.png') no-repeat top center;
width: 2880px;
height: 540px;
}
</style>
</head>
<body>
<div id="bigImage"></div>
</body>
</html>
Answer by Nasser Torabzade for Stop browser from auto scrolling when searching document (ctrl + f)
No, you can not disable that.
you only can scroll to nearest slide on every scroll
event.
// fill lidesTopOffsets array with top offsets
// of your slides when document is ready
var slidesTopOffsets = [100, 200, 300, 400, 500];
var minDifferecne = 10000;
$( window ).scroll(function() {
// find nearest slide
for(var i=0; i < slidesTopOffsets.length; i++){
if(Math.abs($(window).scrollTop() - slidesTopOffsets[i]) < minDifferecne)
minDifferecne = slidesTopOffsets[i];
}
// scroll to nearest slide
$(body).animate({
scrollTop: minDifferecne
}, 0);
});
hope that it helps.
Answer by Nasser Torabzade for Stop browser from auto scrolling when searching document (ctrl + f)
No, you can not disable that.
you only can scroll to nearest slide on every scroll
event.
// fill lidesTopOffsets array with top offsets
// of your slides when document is ready
var slidesTopOffsets = [100, 200, 300, 400, 500];
var minDifferecne = 10000;
$( window ).scroll(function() {
// find nearest slide
for(var i=0; i < slidesTopOffsets.length; i++){
if(Math.abs($(window).scrollTop() - slidesTopOffsets[i]) < minDifferecne)
minDifferecne = slidesTopOffsets[i];
}
// scroll to nearest slide
$(body).animate({
scrollTop: minDifferecne
}, 0);
});
hope that it helps.
Answer by Nasser Torabzade for Stop browser from auto scrolling when searching document (ctrl + f)
No, you can not disable that.
you only can scroll to nearest slide on every scroll
event.
// fill lidesTopOffsets array with top offsets
// of your slides when document is ready
var slidesTopOffsets = [100, 200, 300, 400, 500];
var minDifferecne = 10000;
$( window ).scroll(function() {
// find nearest slide
for(var i=0; i < slidesTopOffsets.length; i++){
if(Math.abs($(window).scrollTop() - slidesTopOffsets[i]) < minDifferecne)
minDifferecne = slidesTopOffsets[i];
}
// scroll to nearest slide
$(body).animate({
scrollTop: minDifferecne
}, 0);
});
hope that it helps.