Closed hohvn closed 4 years ago
Hi, did you always get this error?
yes, always :(
this is bad, what length of your data? here https://github.com/whisller/IrcBotBundle/issues/7 sugestion by adding "\n\r" to data, if this will works this is a magic=)
can you try send small data package? and what logs on nodejs server side?
i added "\n\r" but it not work. Here is nodejs server log
info: socket.io started Listening moneydrop.vtvd.vn:8080 Set origin: moneydrop.vtvd.vn:* debug: setting request GET /socket.io/1/websocket/KSWaZqJTUJzB59dG1Ieg debug: set heartbeat interval for client KSWaZqJTUJzB59dG1Ieg debug: websocket writing 7:::1+0 warn: client not handshaken client should reconnect info: transport end (error) debug: set close timeout for client KSWaZqJTUJzB59dG1Ieg debug: cleared close timeout for client KSWaZqJTUJzB59dG1Ieg debug: cleared heartbeat interval for client KSWaZqJTUJzB59dG1Ieg debug: discarding transport
you can online debug here http://moneydrop.vtvd.vn/moneydrop_node/index.php?r=home/login username:1 password:1
warn: client not handshaken client should reconnect
somthing wrong with handshake
http://moneydrop.vtvd.vn/moneydrop_node/index.php?r=home/login username:1 password:1
please edit hosts: 123.30.211.13 moneydrop.vtvd.vn
try @
I use loadbalancing. have two server. When show Login Form, LB in Server 1, but nodejs client connect Server 2. i thinks it is issue
okie
ii understand this but you connect to nodejs from php
where nodejs server installed, on which server?
Nodejs install on 2 server. I duplicated it
can you show you node-socket component configuration in config file?
seems like you connect via domain to nodejs and load balancer redirect you to other server, maybe add 127.0.0.1 moneydrop.vtvd.vn to /etc/hosts on your servers
Loadbalancing: 123.30.211.13 listen port 6666 for nodejs
Server1: 123.30.211.16 NodeJS in Server 1 run port 8080 Server2: 123.30.211.5 NodeJS in Server2 run port 8080
Client connect to websocket server at 123.30.211.13:6666
Server1: console.php return array( 'basePath'=>dirname(FILE).DIRECTORY_SEPARATOR.'..', 'name'=>'My Console Application',
// preloading 'log' component
'preload'=>array('log'),
// application components
'components'=>array(
'nodeSocket' => array(
'class' => 'application.extensions.yii-node-socket.lib.php.NodeSocket',
// 'host' => '192.168.100.111', // default is 127.0.0.1, can be ip or domain name, without http
'host' => 'moneydrop.vtvd.vn',
'loadbalancing_host' => 'moneydrop.vtvd.vn', 'loadbalancing_port' => 6666, 'port' => 8080 // default is 3001, should be integer ) ), 'commandMap' => array( 'server' => 'application.extensions.yii-node-socket.lib.php.NodeSocketCommand' ) ); main.php
'nodeSocket' => array( 'class' => 'application.extensions.yii-node-socket.lib.php.NodeSocket', // 'host' => '192.168.100.111', // default is 127.0.0.1, can be ip or domain name, without http 'host' => 'moneydrop.vtvd.vn', 'port' => 6666 // default is 3001, should be integer ),
Server 2 like it
now i use your config and i have no errors, can you see nodejs logs?
and i think this is not correct for nodejs because nodejs storing data in memory in this case data on server 1 and server 2 may be different, you can get strange behavior using this configuration, use can be logged in on server 1 but on server 2 is not
oh, you need edit file client.template.js function YiiNodeSocket() { .... var server_host = 'http://<?php echo $nodeSocket->host;?>:<?php echo $nodeSocket->port;?>/client'; var is_loadbalancing = '<?php echo $nodeSocket->loadbalancing_host;?>'; if(is_loadbalancing != ''){ server_host = 'http://<?php echo $nodeSocket->loadbalancing_host;?>:<?php echo $nodeSocket->loadbalancing_port;?>/client'; }
i test it in php
okie, i'll check it. thanks you so much
Hey Hovn, did you get success with Load Balancing? We have same situation...
hi, your nodejs logs the same like above?
We haven't tested on 2 servers at same time yet, I'm just trying to understand if it's possible to make it work with a cluster.
its possible, but need some work, your need something like memcache or redis for node synchronization, somewhere i did it
maybe in newer versions of socket.io that really simple, i do not watch socket.io changes now
Thank you Oncesk, we have patched elephant.io already. Will have a play and see what happens. Any suggestion on best method for autostart. Upstart seems to be a good solution: http://howtonode.org/deploying-node-upstart-monit
not at all)
I have one issue when using load balancing. Please help me
fwrite(): send of 7 bytes failed with errno=32 Broken pipe
/var/www/vtvdigital/dungdetienroi.vtv.vn/moneydrop_node/protected/extensions/yii-node-socket/lib/vendor/elephant.io/lib/ElephantIO/Client.php(244)
232 * @return boolean 233 _/ 234 public function close() { 235 if ($this->fd) { 236 $this->write($this->encode(self::TYPE_DISCONNECT, Payload::OPCODECLOSE), false); 237 fclose($this->fd); 238 return true; 239 } 240 return false; 241 } 242 243 protected function write($data, $sleep = true) { 244 fwrite($this->getSocket(), $data); 245 // wait 100ms before closing connexion 246 if ($sleep) { 247 usleep(100 * 1000); 248 } 249 return $this; 250 } 251 252 / 253 * @return mixed 254 * @throws \RuntimeException 255 / 256 private function getSocket() {