Websocket server (WSS) node connection keeps dropping


I've been given a specific task at my job where I have to check different pieces of information of a list of items.

Currently, I can connect to the WSS of where I work and I'm able to check about 300 items at a time without a problem, but if I double or triple the number of items, the connection simply drops without any error - from 'Connected' it goes to 'Disconnected' just when I'm pressing the button.

I'm not really sure if that's a problem with the servers as they are brand new and well maintained. Is this some kind of a limitation of the Websocket node itself? If so, can it be bypassed somehow?

Meanwhile I've came across the MQTT node - which seems to be connecting through WSS - but unfortunately I don't really know how to configure the entire process as the Websocket node itself seems a lot easier to use than this.

The only solution I've came across would be to connect to the WSS with the 300 items, get the info, drop the connection, switch to the other 300 items, connect to the WSS with the new ones and so on, but it doesn't seem very practical at all.

This is the process:

  • read files from computer
  • use function node to do quick edits for items' names
  • add items in array
  • connect to WSS
  • send the list (array) to the server
  • get info from WSS
  • check the response from the server with the array
  • filter the check in 2 separate files

Any type of help is greatly appreciated!

Really hard to say what is going on without knowing more about the design and how everything fits together.

MQTT uses MQTT as the protocol and not websockets. Though most MQTT brokers will also support connections over websockets so that you can connect direct from a web page rather than a server.

MQTT is a lightweight queueing protocol that gives you more resilience than websockets. Check out the MQTT pages on the Hive website which give an excellent explanation of what MQTT is and how it works. MQTT | The Messaging and Data Exchange Protocol of the IoT (hivemq.com).

If you are connecting to a broker using Node-RED, you need to use the MQTT nodes. If you want to connect to the broker direct from the front-end (browser client) code, then use WS or WSS but you need to configure your broker to support it. With Node-RED, best to configure your front-end to talk to Node-RED over wss and let Node-RED do the talking to/from MQTT.