mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	improved error handling (and labelling) for socket node... but not perfect by a long way...
This commit is contained in:
		@@ -59,7 +59,7 @@
 | 
			
		||||
        outputs:1,
 | 
			
		||||
        icon: "bridge-dash.png",
 | 
			
		||||
        label: function() {
 | 
			
		||||
            return this.name||this.topic||(this.transport+":"+this.port);
 | 
			
		||||
            return this.name||this.topic||("socket "+this.transport+":"+this.port);
 | 
			
		||||
        },
 | 
			
		||||
        labelStyle: function() {
 | 
			
		||||
            return this.name?"node_label_italic":"";
 | 
			
		||||
 
 | 
			
		||||
@@ -55,8 +55,13 @@ function SocketIn(n) {
 | 
			
		||||
				node.send(msg);
 | 
			
		||||
			});
 | 
			
		||||
		});
 | 
			
		||||
		server.on('error', function (e) {
 | 
			
		||||
			if (e.code == 'EADDRINUSE') {
 | 
			
		||||
				setTimeout(node.error('TCP port is already in use - please reconfigure socket.'),250);
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
		server.listen(node.port);
 | 
			
		||||
		node.log('tcp listener on port :'+node.port+'/');
 | 
			
		||||
		node.log('tcp listener on port :'+node.port);
 | 
			
		||||
 | 
			
		||||
		this._close = function() {
 | 
			
		||||
			server.close();
 | 
			
		||||
@@ -130,5 +135,3 @@ RED.nodes.registerType("socket in",SocketIn);
 | 
			
		||||
SocketIn.prototype.close = function() {
 | 
			
		||||
	this._close();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -57,7 +57,7 @@
 | 
			
		||||
        icon: "bridge-dash.png",
 | 
			
		||||
        align: "right",
 | 
			
		||||
        label: function() {
 | 
			
		||||
            return this.name||this.topic||(this.transport+":"+this.port);
 | 
			
		||||
            return this.name||this.topic||("socket "+this.transport+":"+this.port);
 | 
			
		||||
        },
 | 
			
		||||
        labelStyle: function() {
 | 
			
		||||
            return (this.name||!this.topic)?"node_label_italic":"";
 | 
			
		||||
 
 | 
			
		||||
@@ -40,7 +40,8 @@ function SocketOut(n) {
 | 
			
		||||
					node.error('tcp : '+err);
 | 
			
		||||
				});
 | 
			
		||||
				client.connect(this.port, this.host, function() {
 | 
			
		||||
					client.end(msg.payload);
 | 
			
		||||
					try { client.end(msg.payload); }
 | 
			
		||||
					catch (e) { node.error(e); }
 | 
			
		||||
				});
 | 
			
		||||
			}
 | 
			
		||||
			if (this.trans == "udp") {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user