@iobroker/socket-classes 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -69,6 +69,9 @@ io.close();
69
69
  -->
70
70
 
71
71
  ## Changelog
72
+ ### 0.4.5 (2022-06-20)
73
+ * (bluefox) allow to run socket.io behind reverse proxy
74
+
72
75
  ### 0.4.4 (2022-06-09)
73
76
  * (bluefox) Do not show requireLog message
74
77
 
@@ -75,6 +75,10 @@ class SocketCommon {
75
75
  this.server = socketClass(server, socketOptions);
76
76
  }
77
77
 
78
+ if (typeof this.server.of === 'function') {
79
+ this.allNamespaces = this.server.of(/.*/);
80
+ }
81
+
78
82
  server.__inited = true;
79
83
  this.adapter.log.info(`${this.settings.secure ? 'Secure ' : ''}socket.io server listening on port ${this.settings.port}`);
80
84
  }
@@ -93,6 +97,11 @@ class SocketCommon {
93
97
  this.eventHandlers.connect && this.eventHandlers.connect(socket);
94
98
  this._initSocket(socket, cb);
95
99
  });
100
+ // support of dynamic namespaces (because of reverse proxy)
101
+ this.allNamespaces && this.allNamespaces.on('connection', (socket, cb) => {
102
+ this.eventHandlers.connect && this.eventHandlers.connect(socket);
103
+ this._initSocket(socket, cb);
104
+ });
96
105
  }
97
106
 
98
107
  this.server.on('error', (error, details) => {
@@ -101,6 +110,13 @@ class SocketCommon {
101
110
  this.adapter.log.error(`Error: ${(error && error.message) || JSON.stringify(error)}${details ? ' - ' + details : ''}`);
102
111
  }
103
112
  });
113
+ // support of dynamic namespaces (because of reverse proxy)
114
+ this.allNamespaces && this.allNamespaces.on('error', (error, details) => {
115
+ // ignore "failed connection" as it already shown
116
+ if (!error || !error.message || !error.message.includes('failed connection')) {
117
+ this.adapter.log.error(`Error: ${(error && error.message) || JSON.stringify(error)}${details ? ' - ' + details : ''}`);
118
+ }
119
+ });
104
120
 
105
121
  this._updateConnectedInfo();
106
122
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iobroker/socket-classes",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "ioBroker server-side web sockets",
5
5
  "author": {
6
6
  "name": "bluefox",