Node-Red Blynk Websocket Error: read ECONNRESET

Hello,

I am running the latest version of Node-Red on a Raspberry Pi. I am also using the latest version of the Node-Red Blynk contribution. I have also updated my raspberry Pi to the latest version of everything.

I have been successfully pushing data from my temperature sensors to my Blynk app for months.

For some reason, recently the websocket connection is dropping and the app goes offline.

The error in the Node-Red console is:

16 Apr 11:59:28 - [error] [blynk-ws-client:Android App] Websocket Error: read ECONNRESET
16 Apr 11:59:28 - [info] [blynk-ws-client:Android App] Client Error
16 Apr 11:59:28 - [info] [blynk-ws-client:Android App] Connection closed: wss://blynk-cloud.com:9443/websockets

Can anyone suggest what the problem might be please?

I’ve been experiencing Blynk disconnections recently as well. They seem to have started with version 0.9.0 of node-red-contrib-blynk-ws.

I’ve had a Node-Red console open for the past 3 days in attempt to catch an error message, but haven’t had any disconnections since.

For me, the symptoms are that devices will appear as being off-line ij the app, and show as Not Connected in Node-Red. Moving the position of a node (to activate the Deploy button), then doing a Deploy solves the problem.

I checked GitHub and it isn’t flagged as an issue:

@gab.lau is this something you’ve come across?

My setup:
Node-Red V0.20.5
node-red-contrib-blynk-ws v0.9.0
Node.JS v8.15.1
NPM v6.4.1

Pete.

1 Like

Hi,
seen this post I would suggest you to change the connection string from wss://blynk-cloud.com:9443/websockets to wss://blynk-cloud.com/websockets

I would not like there were problems with the incorrect port.

I currently have no connection problems on my nodered on raspberry, but it’s also true that I stayed at version 0.19 of nodered.

I only did some tests with the 0.20 version and it didn’t seem like there were any connection problems.

The problem of disconnection can happen when the internet connection is missing for a few moments …
But as soon as the connection returns on nodered it reconnects to the blynk server or not?

let me know that I will try to investigate the problem.

it would also be advisable to have a longer log to understand before or after the disconnection what happens, for security, enable the ping in the logs that is useful.

Thank you

1 Like

in version 0.8.0 I encountered a problem with the connection timeout that I corrected by increasing the heartbeat to 15 seconds.
If you see the log, in that case, there is no error before logging off:
Websocket Error: read ECONNRESET

so I think the problem is just connectivity.

1 Like

Is it possible to create a re-connect routine if the Blynk connection is lost?

Pete.

1 Like

of course, there is already automatic reconnection after 5 seconds


[file: nodes/blynk-ws-client.js]

var RECONNECT_TIMEOUT = 5; //number of seconds for reconnection when disconnected or socket error

[...]

websocket.on("close", function() {
	node.log("Connection closed: "+node.path);
	node.emit("closed");
	node.logged = false;
	if (!node.closing) {
		clearTimeout(node.tout);
		node.tout = setTimeout(function() {
			startconn();
		}, node.RECONNECT_TIMEOUT * 1000); // try to reconnect
	}
});

[...]

websocket.on("error", function(err) {
	node.error("Websocket " + err);
	node.emit("error");
	node.logged = false;
	if (!node.closing) {
		clearTimeout(node.tout);
		node.tout = setTimeout(function() {
			startconn();
		}, node.RECONNECT_TIMEOUT * 1000); // try to reconnect
	}
});

if possible give me a log following the error

2 Likes

@gab.lau My systems fails to reconnect. I have been restarting Node-Red to reconnect. But, as you say, moving a node and deploying also creates a reconnect.

I have also removed the 9443 from my url and will monitor

1 Like

@gab.lau . Sadly, within 10 minutes of changing the url and restarting, the connection has dropped again.

It didn’t try to reconnect and my app went offline.

17 Apr 09:29:26 - [error] [blynk-ws-client:Android App] Websocket Error: read ECONNRESET
17 Apr 09:29:26 - [info] [blynk-ws-client:Android App] Client Error
17 Apr 09:29:26 - [info] [blynk-ws-client:Android App] Connection closed: wss://blynk-cloud.com/websockets

Is there something I can do to provide more logging information?

Thanks for your help by the way!

What I’ve done is choose Protocol Log - All in the connection settings:

image

then in the PuTTY terminal typed node-red-log
This gives a terminal output for each event that happens, like this:

17 Apr 11:27:59 - [info] [blynk-ws-client:Elephant LEDs] virtualWrite: -> ["vw","7","Auto On, Off in"]
17 Apr 11:27:59 - [info] [blynk-ws-client:Elephant LEDs] virtualWrite: -> ["vw","8","13hrs 33mins"]
17 Apr 11:27:59 - [info] [blynk-ws-client:Elephant LEDs] virtualWrite: -> ["vw",0,"1"]
17 Apr 11:28:14 - [info] [blynk-ws-client:Elephant LEDs] ping
17 Apr 11:28:29 - [info] [blynk-ws-client:Elephant LEDs] ping
17 Apr 11:28:44 - [info] [blynk-ws-client:Elephant LEDs] ping
17 Apr 11:28:59 - [info] [blynk-ws-client:Elephant LEDs] ping
17 Apr 11:28:59 - [info] [blynk-ws-client:Elephant LEDs] virtualWrite: -> ["vw","7","Auto On, Off in"]
17 Apr 11:28:59 - [info] [blynk-ws-client:Elephant LEDs] virtualWrite: -> ["vw","8","13hrs 32mins"]
17 Apr 11:28:59 - [info] [blynk-ws-client:Elephant LEDs] virtualWrite: -> ["vw",0,"1"]
17 Apr 11:29:29 - [info] [blynk-ws-client:Elephant LEDs] ping

I’ve not had a disconnect in the 4 days that I’ve had this running though!

Pete.

1 Like

OK I confirm that there is a problem with the library version 0.9.0, I managed to reproduce the problem, if the connection is lost it does not auto reconnect.

The problem is not present on version 0.8.0

I update you when I solved it.

Greetings

3 Likes

Not sure that it will be of any use now that you’ve managed to re-create the issue, but mine disconnected just before midday today and hasn’t re-connected (it’s now 16:35 in the UK, timestamps are UK time in the error log below). These are the last entries:

17 Apr 11:52:00 - [info] [blynk-ws-client:Elephant LEDs] virtualWrite: -> ["vw","7","Auto On, Off in"]
17 Apr 11:52:00 - [info] [blynk-ws-client:Elephant LEDs] virtualWrite: -> ["vw","8","13hrs 08mins"]
17 Apr 11:52:00 - [info] [blynk-ws-client:Elephant LEDs] virtualWrite: -> ["vw",0,"1"]
17 Apr 11:52:15 - [info] [blynk-ws-client:Elephant LEDs] ping
17 Apr 11:52:30 - [info] [blynk-ws-client:Elephant LEDs] ping
17 Apr 11:52:45 - [info] [blynk-ws-client:Elephant LEDs] ping
17 Apr 11:53:00 - [info] [blynk-ws-client:Elephant LEDs] virtualWrite: -> ["vw","7","Auto On, Off in"]
17 Apr 11:53:00 - [info] [blynk-ws-client:Elephant LEDs] virtualWrite: -> ["vw","8","13hrs 07mins"]
17 Apr 11:53:00 - [info] [blynk-ws-client:Elephant LEDs] virtualWrite: -> ["vw",0,"1"]
17 Apr 11:53:15 - [info] [blynk-ws-client:Elephant LEDs] ping
17 Apr 11:53:30 - [info] [blynk-ws-client:Elephant LEDs] ping
17 Apr 11:53:44 - [info] [blynk-ws-client:Cabinet LEDs] Connection closed: ws://blynk-cloud.com/websockets
17 Apr 11:53:44 - [info] [blynk-ws-client:Lava Lamp Etc] Connection closed: ws://blynk-cloud.com/websockets
17 Apr 11:53:44 - [info] [blynk-ws-client:SPARE] Connection closed: ws://blynk-cloud.com/websockets
17 Apr 11:53:44 - [info] [blynk-ws-client:UK PC Power] Connection closed: ws://blynk-cloud.com/websockets
17 Apr 11:53:44 - [info] [blynk-ws-client:Test_Environment] Connection closed: ws://blynk-cloud.com/websockets
17 Apr 11:53:44 - [info] [blynk-ws-client:Cabinet Spots] Connection closed: ws://blynk-cloud.com/websockets
17 Apr 11:53:44 - [info] [blynk-ws-client:Development] Connection closed: ws://blynk-cloud.com/websockets
17 Apr 11:53:44 - [info] [blynk-ws-client:Elephant LEDs] Connection closed: ws://blynk-cloud.com/websockets
17 Apr 11:53:49 - [info] [blynk-ws-client:Cabinet LEDs] Start connection: ws://blynk-cloud.com/websockets
17 Apr 11:53:49 - [info] [blynk-ws-client:Lava Lamp Etc] Start connection: ws://blynk-cloud.com/websockets
17 Apr 11:53:49 - [info] [blynk-ws-client:SPARE] Start connection: ws://blynk-cloud.com/websockets
17 Apr 11:53:49 - [error] [blynk-ws-client:Cabinet LEDs] Websocket Error: connect ECONNREFUSED 139.59.206.133:80
17 Apr 11:53:49 - [info] [blynk-ws-client:Cabinet LEDs] Client Error
17 Apr 11:53:49 - [info] [blynk-ws-client:Cabinet LEDs] Connection closed: ws://blynk-cloud.com/websockets
17 Apr 11:53:49 - [error] [blynk-ws-client:Lava Lamp Etc] Websocket Error: connect ECONNREFUSED 139.59.206.133:80
17 Apr 11:53:49 - [info] [blynk-ws-client:Lava Lamp Etc] Client Error
17 Apr 11:53:49 - [info] [blynk-ws-client:Lava Lamp Etc] Connection closed: ws://blynk-cloud.com/websockets
17 Apr 11:53:49 - [info] [blynk-ws-client:UK PC Power] Start connection: ws://blynk-cloud.com/websockets
17 Apr 11:53:49 - [error] [blynk-ws-client:SPARE] Websocket Error: connect ECONNREFUSED 139.59.206.133:80
17 Apr 11:53:49 - [info] [blynk-ws-client:SPARE] Client Error
17 Apr 11:53:49 - [info] [blynk-ws-client:SPARE] Connection closed: ws://blynk-cloud.com/websockets
17 Apr 11:53:49 - [info] [blynk-ws-client:Test_Environment] Start connection: ws://blynk-cloud.com/websockets
17 Apr 11:53:49 - [info] [blynk-ws-client:Cabinet Spots] Start connection: ws://blynk-cloud.com/websockets
17 Apr 11:53:49 - [error] [blynk-ws-client:UK PC Power] Websocket Error: connect ECONNREFUSED 139.59.206.133:80
17 Apr 11:53:49 - [info] [blynk-ws-client:UK PC Power] Client Error
17 Apr 11:53:49 - [info] [blynk-ws-client:UK PC Power] Connection closed: ws://blynk-cloud.com/websockets
17 Apr 11:53:49 - [info] [blynk-ws-client:Development] Start connection: ws://blynk-cloud.com/websockets
17 Apr 11:53:49 - [error] [blynk-ws-client:Test_Environment] Websocket Error: connect ECONNREFUSED 139.59.206.133:80
17 Apr 11:53:49 - [info] [blynk-ws-client:Test_Environment] Client Error
17 Apr 11:53:49 - [info] [blynk-ws-client:Test_Environment] Connection closed: ws://blynk-cloud.com/websockets
17 Apr 11:53:49 - [error] [blynk-ws-client:Cabinet Spots] Websocket Error: connect ECONNREFUSED 139.59.206.133:80
17 Apr 11:53:49 - [info] [blynk-ws-client:Cabinet Spots] Client Error
17 Apr 11:53:49 - [info] [blynk-ws-client:Cabinet Spots] Connection closed: ws://blynk-cloud.com/websockets
17 Apr 11:53:49 - [info] [blynk-ws-client:Elephant LEDs] Start connection: ws://blynk-cloud.com/websockets
17 Apr 11:53:49 - [error] [blynk-ws-client:Development] Websocket Error: connect ECONNREFUSED 139.59.206.133:80
17 Apr 11:53:49 - [info] [blynk-ws-client:Development] Client Error
17 Apr 11:53:49 - [info] [blynk-ws-client:Development] Connection closed: ws://blynk-cloud.com/websockets
17 Apr 11:53:49 - [error] [blynk-ws-client:Elephant LEDs] Websocket Error: connect ECONNREFUSED 139.59.206.133:80
17 Apr 11:53:49 - [info] [blynk-ws-client:Elephant LEDs] Client Error
17 Apr 11:53:49 - [info] [blynk-ws-client:Elephant LEDs] Connection closed: ws://blynk-cloud.com/websockets

Pete.

Fixed in library version 0.9.1.

1 Like

@gab.lau How do we install this update on a Raspberry Pi running Raspbian?
There’s no “update to 0.9.1” option in Palette Manager.

Pete.

I also published the package on npm, I think you just have to wait, it should appear in the Palette Manager.

2 Likes

Great. Many thanks for doing this so quickly.

Pete.

@gab.lau Many thanks for helping!

:ok_hand:

1 Like

Now you should see the update of the node inside the palette manager!

The flows.node-red.org registry has problems, I had to force the update.

2 Likes

Thanks @gab.lau, you’re a star!

Pete.